Thursday, 23 August 2018

Recover your MYSQL database if nothing works in Ubuntu/Linux.

Recently I stuck in a situation where after spending many days I couldn't resolve the my MYSQL database connectivity in my Ubuntu system. Although I tried many solutions available on the Internet, but I was unable to resolve it.

Rather than solving my problem I thought that I have made the situation more worst then earlier because of my many hit and try on the server. However, I read at many location to keep a backup of my databases. So I was saved /var/lib/mysql directory it somewhere else.

After no success, I tried to restore databases from my mysql backed up the directory in Ubuntu after a fresh installation of MYSQL database server.

So I was copied /val/lib/mysql folder before a new installation of MYSQL. After successful installation of MYSQL server I tried to restore all my databases in  new MYSQL server like this -

Open a terminal and copy/restore your saved database to MYSQL server using the command-
(I have saved my database to Desktop and database name is itcentre)

sudo cp -r Desktop/mysql/itcentre /var/lib/mysql

enter your sudo password

after coping your database file also copy these files of your /var/lib/mysql folder to the server



sudo cp  Desktop/mysql/ibdata1 /var/lib/mysql
sudo cp  Desktop/mysql/ib_logfile0 /var/lib/mysql
sudo cp  Desktop/mysql/ib_logfile1 /var/lib/mysql
sudo cp  Desktop/mysql/debian-5.7.flag /var/lib/mysql

sudo chown -R mysql:mysql /var/lib/mysql


if there is no error your database is successfully restored to MYSQL server.


Good luck !!!

No comments:

Post a Comment

Change image source dynamically on hyperlink

 Changing image source dynamically using JQuery. Here in this example I have created there hyperlink and stored all images in the same folde...