Saturday, January 11, 2014

No write since last change (use ! to override)

No write since last change (use ! to override)

If you are getting this error after using :q while saving your changes in command line editor.
Run following commands
:w
then
:q
Now it will ask to save the changes.

Tuesday, January 7, 2014

X11 forwarding request failed on channel 0

X11 forwarding request failed on channel 0
Error: no display specified

If you are facing this error while connecting remote server through ssh -X, see the post below.

When you try to open display of remote server on your system, you may get this error.

To remove this error, follow the solution.

Solution :

1) Open file /etc/ssh/sshd_config on remote server where you want to connect.

2) The following attribute must be uncommented in the file as well as set as yes.
X11Forwarding yes
Now restart ssh/sshd and try to connect to the server.

3) If X11Forwarding has been set as yes in the file and it is still showing same error, Find the following attribute in the file, uncomment it and set it no.
X11UseLocalhost no
4) Now restart ssh/sshd and try to connect to the server.
service ssh restart
or
service sshd restart
According to your Linux Distribution.

If you are still facing the problem after restarting ssh service, check there is a file .Xauthority in home directory of server.
If it is not there create it using following command.
First log in to the server command prompt using ssh and run following command there.
mkxauth -c
Now restart ssh/sshd and try again.

Wednesday, December 11, 2013

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.