Saturday, January 11, 2014

Mysql database back up using source directory

Mysql database recovery using source directory

If you do not have .sql file of your mysql database, it doesn't mean you can not deploy the database on the server. If you have source directory of mysql database, it is quite fine to recover database.

Here is the path of source directory of mysql databases :
If you are using xampp, the path is /opt/lampp/var/mysql
If you are using default mysql, the path is /var/lib/mysql

In source directory, it saves the data as .frm files.

If phpmyadmin is not opened because of corrupt mysql packages (re-installation is not possible) and command line mysql is not working, now it looks like your all databases are gone but if source directory is fine, every thing is fine.

Keep back up of this source directory.

Now if you want to shift the databases on other system, just copy source directories of databases and put into mysql source directory of other system. Now you will try to see these databases in phpmyadmin or using command line but it doesn't show any data.

Here is the most important part, it does not show data because of wrong owner and permission. You need to set it correct.
# sudo chown -R mysql:mysql /opt/lampp/var/mysql/new-database-dir
Now set owner and group both mysql for this new directory.
# sudo chown -R mysql:mysql /var/lib/mysql/new-database-dir
(according to your mysql)

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 /opt/lampp/var/mysql/new-database-dir
or
# sudo chmod -R 755 /var/lib/mysql/new-database-dir
(according to your mysql) 

Note : This is one of the efficient way to deploy mysql database without using .sql file. Just put this mysql database directory(containing .frm files) in source directory of mysql, set the proper owner and permission and your mysql database is deployed.

Ubuntu - Linux - E: Package has No installation candidate

E: Package has No installation candidate

This is one of the common Ubuntu error you get while installing new packages.
If you are getting it for any specific package then you should update your apt repository by adding this package.

But if you are getting this error for every package, here is the solution.

Run following command.
# sudo apt-get update
Now try to install the package again, you should not get the error.

Find the public IP address of the system using command line

Commands to find Static IP address of the server

If you want to find the public IP address of the system. Run following commands.
# wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
If this is not working for you, try this.
# curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
It does not show you the LAN IP address, it shows the IP address that you can access out side the LAN, if it is static.
# curl ifconfig.me
One of these four should work for you.
# lynx -dump ifconfig.me | grep 'IP Address'

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.