How to create MySQL data directory with mysql_install_db

On a Debian 7 server, the MySQL database got corrupted, which caused the MySQL database to keep crashing. I was able to take a backup of the database following InnoDB Recovery instructions at

Once I have the Database backup taken, I took a backup of the MySQL data directory /var/lib/mysql and removed it.

To recreate the MySQL data directory, I run the mysql_install_db command, but it failed with the error message “FATAL ERROR: Could not find my-default.cnf”

Advertisement

root@srv01 ~ # mysql_install_db --defaults-file=/etc/mysql/my.cnf --user=mysql --datadir=/var/lib/mysql
FATAL ERROR: Could not find my-default.cnf

If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.

root@srv01 ~ #

It is fixed by copying /etc/mysql/my.cnf to /usr/share/mysql/my-default.cnf

cp /etc/mysql/my.cnf /usr/share/mysql/my-default.cnf
Add a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Advertisement