Recover Mysql Database On Debian Based Linux Systems
  1. Sometimes we might need to recover MySQL database on Linux. In other words we want the MySQL database server use the existing/old database directories.
  2. As root, install the Mysql server first: apt-get install mysql-server-5.0
  3. As root, run mysql command in the terminal window
    • use mysql
    • select password from user where user='debian-sys-maint';
    • take down the password for debian-sys-maint, say "*PASSWORD"
  4. As root, stop the mysql-server, run /etc/init.d/mysql stop
  5. Rename the mysql directory in /var/lib: mv /var/lib/mysql /var/lib/mysql.orig
  6. Move or link the old mysql directory to /var/lib: ln -s /path/to/old/msyql /var/lib/mysql
  7. Start MySQL Server in safe mode and bypassing grant-tables: mysqld_safe —skip-grant-tables &
  8. mysql
    • use mysql;
    • update user set password='*PASSWORD' where user='debian-sys-maint';
    • flush privileges;
  9. /etc/init.d/mysql stop
  10. /etc/init.d/mysql start

See also:

  1. MySQL change root password
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License