Copying/restoring mysql databases
I restored (copied) my mysql databases to a newly reinstalled machine by copying /var/lib/mysql. However I was getting a "ERROR 12: Can't read dir of blah". It turned out I forgot to change ownership to mysql, i.e., chown -R mysql:mysql /var/lib/mysql.
There is another problem. Debian uses the debian-sys-maint user in its init script. This user gets created when mysql-server is installed with a random password (see /etc/mysql/debian.cnf). When I copied the mysql database over it overwrites the debian-sys-maint user with the old password generated for my previous system so it couldn’t start the mysql server.
To fix this I deleted debian-sys-maint from the mysql user table then ran dpkg-reconfigure mysql-server which creates this user again.
Leave a Reply
You must be logged in to post a comment.