XAMPP : Change the Default mysql data directory

XAMPP : Change the Path of mysql source directory

Steps :

 XAMPP's default mysql source directory is  /opt/lampp/var/mysql
    Here it stores all databases in source file format.

If you want to change the path of this default directory, the most common reason should be that you do not have enough space in your filesystem and your large size databases are making it worse. :)

Now here is the solution.

Solution : 1
1) Stop the xampp
# sudo /opt/lampp/lampp stop
2) Copy database directory using command line. If you use command line, it stores the owner and permissions. Now suppose new path is in /home.
# sudo cp -pr /opt/lampp/var/mysql /home
3) Rename the original database directory for back-up.
# sudo mv /opt/lampp/var/mysql /opt/lampp/var/mysql_old
4) Make symbolic link from new mysql directory to old mysql directory
# sudo ln -s /home/mysql /opt/lampp/var
5) Start xampp
# sudo /opt/lampp/lampp start
6) If every thing is fine, you can delete the backup directory
# sudo rm -r /opt/lampp/var/mysql_old

Note :
If you copy the mysql directory using nautilus (Right click, copy and paste), you can face problem while starting mysql because the owner and permissions are not always same while copying using nautilus that's why you need to use command line.


Solution : 2 (If above solution is not working for you)
1) Create the new directory new-dir in other partition.

2) Now stop XAMPP and change the following attribute in the file /opt/lampp/etc/my.cnf under [mysqld]
datadir         =  /path-of-other-partition/new-dir
[mysqld] user = nobody port = 3306 socket = /opt/lampp/var/mysql/mysql.sock datadir = /media/DGHI-KJHL-023/mysql
If it is not there under [mysqld], just add it yourself
so it will look like this.

3) Copy the directory /opt/lampp/var/mysql/mysql
and /opt/lampp/var/mysql/phpmyadmin and paste into /path-of-other-partition/new-dir

Most important step
4) Now set owner and group both mysql for this new directory.
# sudo chown -R mysql:mysql /path/of/other/partition/new-dir

5) Set the permission 755(maximum open) for the new directory, you can set little less according to security of your network.
# sudo chmod -R 755 /path/of/other/partition/new-dir

Wrong permission can be cause of the error "couldn't start mysql"

6) Start XAMPP.
# sudo /opt/lampp/lampp start
Now new databases will be created in this new directory.

7) If you want to shift old databases in new place, just copy the directory of the database from /opt/lampp/var/mysql and paste into
/path-of-other-partition/new-dir

Make sure about step-4 & step-5.

8) If you face problem while starting and stopping XAMPP, Use 'Kill mysqld' to kill all mysqld processes.
killall mysqld
Now start XAMPP, you will not face this problem.

#1129 - Host is blocked because of many connection errors

#1129 - Host is blocked because of many connection errors


If phpmyadmin is not working because of above error, Here is the solution.

Solution : 1

Restart the mysql
If you are using Ubuntu, Debian or Mint
# service mysql restart
or
If you are using CentOS, fedora or RHEL
# service mysqld restart

Solution : 2

Run the command in the terminal (mysql should be in running state.)
# mysqladmin flush-hosts -h hostname -u username -p

XAMPP : Another web server daemon with ssl is already running

XAMPP ERROR : Another web server daemon with ssl is already running


If you are facing this error, it means your ssl port is already busy.
This is very simple problem and you do not need to change your apache port.

ssl service uses port 443. If you are running a process which is using this port and after that you are starting xampp, xampp doesn't start. The reason is xampp's Apache uses 80 & 443 both ports.

Solution :
Step-1
You need to stop the service which is using port 443.
Step-2
Start the XAMPP.
Step-3
Start that service again.

If you do not know about that service which is using port 443, find it using
# netstat -lnp | grep :443
It will list the service which is using port 443. Now you can stop it.

If you do not know how to stop it, just kill the service using
# killall service-name
I am giving you an example of this.
I am getting this error and I tried to find which service is using port 443. I found it using netstat command and kill it using killall command.

You can kill it using it's pid too.
See the screenshot what I did to solve the problem.

# Click on the screen shot to see the bigger view.


Linux - Make pen drive as RAM

 Linux - Use a USB drive as RAM

Actually I am going to clear it first that it does not increase your RAM memory, the process is used for improved performance by cpu using increased swap space but it works same as increased RAM.

It increases your swap space of the system according to size of your pen drive. Suppose you have given 2GB swap space in your system and now you use 8GB pen drive for increased swap space, it shows total swap space around 10 GB.

Follow the process to increase performance of your system.

First make sure that your pendrive is empty and there is no necessary data in it otherwise it will be lost.
Find the device name of your pendrive using command

fdisk -l
In my case, it is /dev/sdb1
 
Now unmount the pendrive using

sudo umount /dev/sdb1
Create swap partition using

sudo mkswap /dev/sdb1
Make it enabled using
sudo swapon -p 32767 /dev/sdb1
32767 is the priority,  The maximum priority can be 32767 and the lowest 0.

To see if swap space is increased or not, Run following command
cat /proc/swaps

If you need to take the pendrive out, do the safety removal process using

sudo swapoff /dev/sdb1
Now you can remove your pendrive but it will not be detected, you need to format it in fat32 or NTFS (in any familiar partitions)
Now pen drive will not be detected, format it again in fat32 using

mkdosfs -F32 -v -n "" /dev/sdb1/span>

Now pendrive will be detected again.

Note :
Swapping is necessary for two important reasons. 

First, when the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately. 

Second, a significant number of the pages used by an application during its startup phase may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other applications or even for the disk cache. 

Netbeans - Choose Project Please Wait Error

Netbeans does not load php projects.
Netbeans - ' Scanning Projects ' Process Hangs




If you are not able to add projects in Netbeans. Whenever you want to add, it sticks on 'choose project' status.

Nebeans requires Java (jdk) to start and use. The problem is because you have installed openjdk , If you install oracle java, you will not face this problem.

Click here to see how to install Oracle Java or if you are using Ubuntu, click here.
Now open Netbeans.

But

If you are facing problem to install Oracle Java or the process is very Lengthy, this post is for you.

Follow these steps and you will get rid off this Netbeans issue.

If you have installed openjdk-6 or openjdk-7, just leave it, do not remove it.

Download complete package of netbeans with oracle java from here
If you are using 32 bit system, download the file Linux x86 or if you have 64 bit system, download the file Linux x64

Now you have to execute this file, 
Run following command to execute this file :
# sh /path/of/downloaded/sh-file.sh
Complete the wizard.

Note :
If above command gives you permission denied error, it means your downloaded sh file is not executable, make it executable using
chmod a+x /path/of/downloaded/sh-file.sh
When Netbeans will be installed, Open Available Plugin tab and Install php plugins from it.

Now you are ready to use Netbeans for PHP projects without getting "choose project please wait" error.

Fatal error: session_start(): Failed to initialize storage module: files (path: ) in /usr/share/phpmyadmin/libraries/session.inc.php on line 81

 Fatal error: session_start(): Failed to initialize storage module: files (path: ) in /usr/share/phpmyadmin/libraries/session.inc.php on line 81

Solution : 1
Add the parameter in the file php.ini
session.save_path = "/tmp"
Restart apache.

Solution : 2
If you are using Debian or Ubuntu and you have tried solution : 1 and  it still shows above error, remove following lines from /etc/phpmyadmin/apache.conf
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_admin_flag allow_url_fopen Off
php_value include_path .
php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/
</IfModule>

Now restart apache2 & mysql and try again.

phpmyadmin - max upload file size is not changed

phpmyadmin - max upload file size is not changed after making changes in php.ini

If you have changed upload_max_filesize & post_max_size both parameters in php.ini but still it does not show changed maximum upload file size in import section.

You have restarted apache and you have done every thing what was suggested to you but still you are unable to see increased max upload file size.

 Now you are at correct place, just follow this.

Make a file .htaccess and put following text in it.
php_value upload_max_filesize 2048M php_value post_max_size 2048M
where 2048M is your max upload file size, you can set whatever value you want.

Put this file into phpmyadmin directory.

Now restart apache and mysql and see import page of phpmyadmin. It will show the limit you have put in .htaccess file.

The path of phpmyadmin directory is /usr/share/phpmyadmin. If you are using LAMPP, the path of phpmyadmin directory is /opt/lampp/phpmyadmin

Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration Action 'configtest' failed.

Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed. The Apache error log may have more information....fail!

Ubuntu - Apache2 error

If you are getting this error, it means you have used rewrite engine in your script but rewrite module is disabled right now.

To solve this error, just enable the rewrite module.

If you are using ubuntu - apache2, run this command in terminal
# sudo a2enmod rewrite # service apache2 restart
Now try again.

If you are getting this error in RHEL/CentOS or in LAMPP, click here.

Enable and Disable Apache modules

Enable and Disable Apache modules in Ubuntu or CentOS

If you want to enable or disable any module in Apache, this post may be helpful for you.

Enable or Disable Apache module in RHEL or CentOS

In CentOS, we can see all Apache modules in the directory /etc/httpd/modules.
These modules are enabled in the file httpd.conf using following code. 
Here is an example of rewrite module.
LoadModule rewrite_module modules/mod_rewrite.so
If you want to disable this module, just comment the line and restart Apache, now it does not load the module.

If you want to enable it again, just uncomment the line and restart apache. 
Using this method we can enable and disable any module of Apache on CentOS.

Enable or Disable Apache module in LAMPP

The process in LAMPP in same as CentOS.
All modules are mentioned in the file /opt/lampp/etc/httpd.conf
If you want to disable any module, just comment the line and restart LAMPP, now it does not load the module.

If you want to enable it again, just uncomment the line and restart LAMPP. 
Using this method we can enable and disable any module of Apache in LAMPP.

Enable or Disable Apache module in Ubuntu

If you want to disable apache module in ubuntu-apache2, run following command
$ sudo a2dismod module_name

If you want to enable apache module in ubuntu-apache2, run following command
$ sudo a2enmod module_name

Suppose you want to disable or enable rewrite module, you should run :
$ sudo a2dismod rewrite $ sudo a2enmod rewrite



unetbootin error - 7z not found. This is required for either install mode. Install the "p7zip-full" package or your distribution's equivalent.

unetbootin error - 7z not found. This is required for either install mode. Install the "p7zip-full" package or your distribution's equivalent.

If you are trying to make a bootable pen drive using Unetbootin and it gives you above error.
Now because of this error you are not able to make bootable pen drive, here is the solution for you.

If you are using debian or ubuntu
Install from command line
# sudo apt-get install p7zip
OR
If you are still getting the problem
Go to this link and download the p7zip according to your configuration.

Here you can download the deb file.

Now install it and try to make bootable pen drive again.

You will not get this error.

NOTE : If your machine is 32 bit machine, download i386, if you are using amd 64 bit, download amd64 version.

You can find these links at bottom of the page.

If you are using CentOS or Fedora
Install from command line
# sudo yum -y install p7zip

Run a Shell script in a Perl script

Call a Bash script in a Perl script
Run a Shell script inside Perl script
Execute Shell script in a Perl script

If you making a perl script and somewhere you want to run a bash script inside that perl script.

It can be done easily through the following piece of code.

Here is a example of an infinite loop in shell script which prints 0 infinite times.
If you run this shell script statement in terminal, it gives you 0 infinite times.
while [ 4 -le 5 ]; do  echo 0;  done;

Suppose I want to run this Shell script from a Perl script, Now I add this line of code in my perl script.

system("bash -c 'while [ 4 -le 5 ]; do  echo 0;  done;'");

Now My Perl script runs this shell script code.

Suppose this line of code is saved in a shell script file as script.sh, now if I want to run this shell script from my perl script.

I simply add this line of code in my Perl script.
system("bash -c '/root/Desktop/url.sh'");

E: Sub-process /usr/bin/dpkg returned an error code (1)

E: Sub-process /usr/bin/dpkg returned an error code (1)

If you are installing any package in Ubuntu or Debian and it gives above error

Solution : 1
Run following command in terminal
sudo dpkg --configure -a
Now try to install your package again.

Solution : 2
Run following command in terminal
sudo apt-get -f install
Now try to install your package again.

Solution : 3
Open file /var/lib/dpkg/status and remove the whole block of corrupted packages.
Now try to install your package again.

Format USB pen drive using command line on Linux


Format USB pen drive on Linux

First find the device path of the USB device using following command
fdisk -l
Output looks like this.

Now you can find the device path of the USB drive.
Suppose it is /dev/sdb1

Format pen drive in fat32 filesystem, Run following command
mkdosfs -F32 -v -n "" /dev/sdb1

Format pen drive in NTFS filesystem, Run following command
mkntfs -Q -v -L "" /dev/sdb1

Format pen drive in ext4 filesystem, Run following command
mkfs.ext4 -j -O extent -L "" /dev/sdb1

Format pen drive in ext3 filesystem, Run following command
mkfs.ext3 -L "" /dev/sdb1

Format pen drive in ext2 filesystem, Run following command
mkfs.ext2 -L "" /dev/sdb1

Format pen drive in fat16 filesystem, Run following command
mkdosfs -F16 -v -n "" /dev/sdb1

Note :
Change /dev/sdb1 with your device path.

Install Netbeans IDE on Ubuntu in three easy steps

Install Netbeans IDE on Ubuntu :

Step -1
Download sh file of Netbeans IDE from here according to your requirement.
If you want it for JAVA SE / EE or C/C++ or PHP or all. They have all options.
Download your desired sh file.

Step-2
Install openjdk on Ubuntu. Run following command.
sudo apt-get install openjdk-6-jdk

or
sudo apt-get install openjdk-7-jdk

Step-3
Now execute the downloaded sh file of Netbeans IDE.
sh /path/of/downloaded/sh-file.sh

Complete the wizard.

Note :
If third step gives you permission denied error, it means your downloaded sh file is not executable, make it executable using
chmod a+x /path/of/downloaded/sh-file.sh


Configure: error: xml2-config not found. Please check your libxml2 installation

Configure: error: xml2-config not found. Please check your libxml2 installation

If you find this error in CentOS, Fedora or RHEL,  Run
# yum install libxml2-devel

If you find this error in Ubuntu or Debian, Run
# apt-get install libxml2-dev


configure: error: Please reinstall the BZip2 distribution

configure: error: Please reinstall the BZip2 distribution

If you find this error in CentOS, Fedora or RHEL, Run
# yum install bzip2-devel

If you find this error in Ubuntu or Debian, Run
# apt-get install libbz2-dev


Linux CPU / Memory Utilization and other Performance

Linux CPU Load

If you want to see the CPU Load details as well CPU utilization, try following command.
# top
Press q to return on command prompt. q is for quit.

or more graphical representation
# htop
Press to return on command prompt. q is for quit.

or Install sysstat & try following command :
# mpstat
You can see CPU usage in percentage using
# sar
as well as you can use
# iostat
If you want to know who is eating cpu
# ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

Web Server Monitoring Tools

WebSite Monitoring Tools

NagiosNagios is a powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes.

WebSitePulseThe WebSitePulse Website monitoring service provides 24/7 mission-critical remote availability monitoring and performance measurement of your website from end-user perspective. With two service options, Performance website monitoring simulating repeat user and Full-page website monitoring, simulating first-time user experience, this monitoring service gives you real insight into what your end-users are experiencing with your website.

InternetSupervision : InternetSupervision.com monitors the availability, performance, and content of your website, web server and internet services from our UL approved offices with 24/7 personnel in Washington DC, Detroit, Chicago, Los Angeles, and Santiago, Chile. We also have remote check points in Gloucester, UK, and Sydney, Australia. Learn more about our services and plan pricing.

site24x7 : Keep track of the performance of multi-step web applications or business transactions. It can remotely monitor the availability and performance of business-critical web applications that involves multiple web transactions.

hosttracker : They provide Monitoring an unlimited number of resources, Distributed monitoring, Monitoring period – every 1/5/15/30/60 minutes, Possible monitoring of CGI scripts’ operation, The HEAD/POST/GET HTTP-methods support, Ability to specify parameters passed to a CGI script, Keyword presence control on a page and many more.

Pingdom : Pingdom makes it easy for user to monitor the uptime and performance of the website or server.

monitor.us : They provide Tracking website availability and performance from different locations in major countries and traffic destinations, Website uptime checks,  using HTTP, HTTPS, PING, DNS, Agentless MySQL checks, Email checks using SMTP, POP3, IMAP protocols, Public IP checks using TCP, UDP, SSH and IMCP protocols, VoIP checks using SIP protocol, Webpage content checks, Instant failure alerts via email, IM, SMS or live voice, SLA Reporting - detailed reporting with service level metrics per interval and many more.

Are my sites upIt is a free, ad-supported web server monitoring tool. Their plans will check the sites as frequently as once per minute. User get unlimited email and SMS notifications (in the US, International SMS is available) and they tell user that why was down by providing the HTML status error code, when possible. They provide an iPhone application, RSS feeds, webhooks, keyword search, premium-level support, email notifications to multiple addresses, multiple user accounts voice calls.

ObservuObservu monitors your websites from multiple locations and combines it with measurements collected on your servers. Notification by E-mail, SMS and Voice calls will allow you to respond quickly and improve your quality of service dramatically.

ServiceUptime : Free monitoring account includes one monitoring service (any port or service) checked every 30 minutes. Free account has all necessary features to keep the track of your website uptime and is limited in some advanced features and check frequency only. There is no limitations on worldwide locations so your service will be monitored from all over the world. 

Montastic : Montastic monitors the sites and alert when there is an error. They send an email when the site goes down as well as when the site goes back up. They read statuses via RSS, Mac, PC, Android widgets and API .They support for HTTP, HTTPs and any port number and HTTP authentication. They verify presence or absence of keyword on a web page Monitoring frequency up to every 5 minutes.

BasicStateIt is a free web site uptime monitor service, server and network failure alerts.  The free uptime monitoring service monitors http services. The test attempts to retrieve the home page at a fixed interval of fifteen minutes. For additional capabilities exactstate.com offers http, https, smtp, imap, pop3, ftp, ssh, telnet and custom tcp ports at intervals between 1 to 20 minutes. Email blacklist monitoring of dnsbl blacklists and rhsdnsbl blacklists is also available for both individual servers and bulk ip address netblocks. Be sure to check out the 2 for 1 bonus offer before deciding on your first purchase. 

Top web server performance tools for Linux

Top Web Server Performance /  Load / Stress Testing tools for Linux :

Apache JMETER :  The Apache JMeter™ desktop application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions. 

Curl Loadercurl-loader (also known as "omes-nik" and "davilka") is an open-source tool written in C-language, simulating application load and application behavior of thousands and tens of thousand HTTP/HTTPS and FTP/FTPS clients, each with its own source IP-address. In contrast to other tools curl-loader is using real C-written client protocol stacks, namely, HTTP and FTP stacks of libcurl and TLS/SSL of openssl, and simulates user behavior with support for login and authentication flavors. 

LoadUILoadUI is a Open Source Load Testing solution that is free and cross-platform. With a visual, drag-and-drop interface, it allows you to create, configure and redistribute your Load Tests interactively and in real-time. In a single test environment, LoadUI provides complete test coverage and supports all the standard protocols and technologies.

httperfHttperf is a tool for measuring web server performance. It provides a flexible facility for generating various HTTP workloads and for measuring server performance. The focus of httperf is not on implementing one particular benchmark but on providing a robust, high-performance tool that facilitates the construction of both micro- and macro-level benchmarks

SiegeSiege is an http load testing and benchmarking utility. It was designed to let web developers measure their code under duress, to see how it will stand up to load on the internet. Siege supports basic authentication, cookies, HTTP and HTTPS protocols. It lets its user hit a web server with a configurable number of simulated web browsers. 

TsungTsung can be used to stress HTTP, WebDAV, SOAP, PostgreSQL, MySQL, LDAP and Jabber/XMPP servers. Tsung is a free software released under the GPLv2 license. The purpose of Tsung is to simulate users in order to test the scalability and performance of IP based client/server applications. You can use it to do load and stress testing of your servers. Many protocols have been implemented and tested, and it can be easily extended. 

GrinderThe Grinder is a JavaTM load testing framework that makes it easy to run a distributed test using many load injector machines. It is freely available under a BSD-style open-source license.

openLoadOpenWebLoad is a tool for load testing web applications. It aims to be easy to use and providing near real-time performance measurements of the application under test. This is particulary useful when you are doing optimization as you can see the impact of your changes almost immediately. 

FunkLoadFunkLoad is an open source functional and load Web tester whose main use cases are functional testing of Web projects (and thus regression testing as well), performance testing, load testing (such as volume testing or longevity testing), and stress testing.

userdel: user is currently logged in

userdel: user `username` is currently logged in

If you are trying to remove / delete a user 
# userdel username
and it shows following warning

userdel: user `username` is currently logged in

Now you are not able to remove the user.

Solution :

Run following command.
# pgrep -u username
In place of word username, put your username which is giving you trouble.
Now kill the instances using
# killall -u username
Now try to delete your user but you are still getting same message, check again
# pgrep -u username
You can't run delete user command successfully until you get the instances of the same user using pgrep command.
The result of pgrep command should be blank, No result.




Linux : crontab permission denied

Linux : user can't create/update crontabs
Crontab permission denied for Linux user
Allow user to create crontabs on Linux

By default the permission of file /usr/bin/crontab is
 -rwxr-xr-x 1 root root 34784 Apr 11 10:58 /usr/bin/crontab
Only root can create/update/delete crons.

If you want to allow user to create crons on Linux system, follow this.

a) If you are using CentOS, Fedora or RHEL
The permissions of crontab file should be
 -rwsr-xr-x 1 root root 34784 Apr 11 10:58 /usr/bin/crontab 
Owner and Group both should be root for the file as well as SUID bit should be set.
The ‘s’ in user field in place of ‘x’ indicates that SUID bit is set. 
To set SUID, Run following command
# chmod 4755 /usr/bin/crontab
or
# chmod u+s /usr/bin/crontab

b) If you are using Debian or ubuntu
The permissions of crontab file should be 
 -rwxr-sr-x 1 root crontab 34784 Apr 11 10:58 /usr/bin/crontab 
Owner should be root but the Group should be crontab as well as SGID bit should be set.
The ‘s’ in group in place of ‘x’ indicates that SGID bit is set.  
To make Group 'crontab', run following command.
# chgrp crontab /usr/bin/crontab
To set SGID, Run following command
# chmod 2755 /usr/bin/crontab
or
# chmod g+s /usr/bin/crontab

Filezilla - Response:530 Sorry, the maximum number of clients (n) from your host are already connected

Filezilla - Response:530 Sorry, the maximum number of clients (n) from your host are already connected

Solution 1
Open filezilla.
File -> site manager -> select your 'My Sites' entry -> transfer settings -> uncheck the check box "Limit number of simultaneous connections"

Try again.

Solution 2 -
Close all connections of same site. Do not open multiple filezilla instances for same site.

Restart filezilla.

Create mysql user for remote host log in

Log into mysql server from remote host

I am showing you a method to create mysql user for remote login.

I am going to give it all privileges so be careful. The details should not be given in wrong hands.

Create a user using following commands. Select any username and any password of your choice.
mysql> GRANT USAGE ON *.* TO 'new-username'@'%' IDENTIFIED BY 'new-password';
Now run this command. Use same username and password which you used in above command.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'above-username'@'%' IDENTIFIED BY 'above-password' WITH GRANT OPTION;
Restart mysql.

Suppose my username is elex and password is linuxamination. My system's IP is 192.168.1.7. Now another user of my LAN whose IP is 192.168.1.8 wants to connect to my system's mysql server.

The other user should open it's terminal and run following command.
# mysql -h 192.168.1.7 -u elex -p'linuxamination'

Now 1.8 is  logged into my mysql server. Since user elex has full privileges so 1.8 can update/drop any database.

ERROR 1130 (HY000): Host is not allowed to connect to this MySQL server

ERROR 1130 (HY000): Host is not allowed to connect to this MySQL server

If you are trying to log into mysql server of remote host and you are getting this error, there can be several reasons that you are getting this.

1) You can not log in with blank/No password on remote host  otherwise it gives following error

ERROR 1045 (28000): Access denied for user 'username'@'hostname' (using password: NO)
Generally root account does not have password and you use blank password to log into root account but there must be a password to log into remote host mysql server.
Do not change it with no password attribute just like your localhost. It is very important that remote host must have mysql password otherwise it would be biggest security loop hole.

2) If you have created new user and you have set password for it. Now it is time to check hostname. If you are logging into mysql server of remote host, you must be using IP for it's hostname. If hostname is localhost, you can not log into the mysql server. This host name is for users of the server, it is not for remote host.

3)  If hostname is IP of the server, still you can not log into the mysql server. This host name is for users of the server, still it is not for remote host.

4) Port 3306 should be opened on remote host and if server is RHEL, Fedora, CentOS or similar one. The port should be defined in IP table rules.

Host name should be '%' as well as username and password both should be defined for the host name or you can say A user should have host name '%' to log into mysql server on remote host.

Now you can log into mysql server on remote host using IP.

Set the proper permission(create/drop database, create/drop table etc) for this user using 
privileges options.

click on the image for readable view.

In this example, username is admin101 & admin11, password is admin and hostname is %. Now anyone can log in from remote host into this mysql server using IP as a hostname and above given username & password.

Be careful about privileges. User can misuse if you are not careful enough.
# mysql -h 192.168.1.7 -u admin101 -p'admin'

where 192.168.1.7 is IP of the remote server
admin101 is username of mysql user on remote host
admin is password for this user.
There is no space between -p & '

For mysql remote login, Read this.

500 OOPS: cannot change directory:/home/username

ftp error : 500 OOPS: cannot change directory:/home/username

Solution I : 
Disable SELinux. To see, how to disable it, Click here.

Solution II :
If you do not want to disable SELinux. Follow this.
Check directory status.
$ getsebool -a | grep ftp
If ftp_home_dir is set to off, the error can be there, we need to make this attribute on using
$ setsebool -P ftp_home_dir on
Now restart vsftpd and try to reconnect again.
or
$ setsebool -P ftp_home_dir=1
Now restart vsftpd and try to reconnect again.

If you are still facing error, check the username directory inside /home directory.
The username directory should be there to log in to the ftp account.

vsftpd : 550 create directory operation failed

ftp error : 550 create directory operation failed 

Solution I : 
Disable SELinux. To see, how to disable it, Click here.

Solution  II :
If you do not want to disable SELinux. Follow this.
Run following commands.
# chcon -Rv --type user_home_dir_t /path/of/ftp/directory
OR
# chcon -t public_content_rw_t /path/of/ftp/directory # setsebool -P allow_ftpd_anon_write=1
Now restart vsftpd and try to reconnect again.

Solution  III :
If you are getting this error on ubuntu then the SELinux solution might not work for you because it is not installed by default on ubuntu.

Open vsftpd.conf and uncomment following line.

# write_enable=YES
Restart vsftpd.

Now try to connect but if you get following error

# 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
Add this attribute in vsftpd.conf
# allow_writeable_chroot=YES
Restart vsftpd.

Now you should be able to create and remove directory/files using filezilla.

Related Posts Plugin for WordPress, Blogger...