Recover Mysql Database On Debian Based Linux Systems
- 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.
- As root, install the Mysql server first: apt-get install mysql-server-5.0
- 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"
- As root, stop the mysql-server, run /etc/init.d/mysql stop
- Rename the mysql directory in /var/lib: mv /var/lib/mysql /var/lib/mysql.orig
- Move or link the old mysql directory to /var/lib: ln -s /path/to/old/msyql /var/lib/mysql
- Start MySQL Server in safe mode and bypassing grant-tables: mysqld_safe —skip-grant-tables &
- mysql
- use mysql;
- update user set password='*PASSWORD' where user='debian-sys-maint';
- flush privileges;
- /etc/init.d/mysql stop
- /etc/init.d/mysql start
See also:
page revision: 2, last edited: 22 Sep 2008 12:02