mysql_install_db

Sometimes you want to delete the mysql data folder. But the mysql server will not start after removing because of missing default tables and files. For this reason mysql offers a script mysql_install_db to create all necessary folders.

Create mysql data folder

We will stop mysql service, remove data folder and create a new one.

Possible output

Using parameter defaults_file

In some cases your mysql installation is not default and you want to use a special config with other parameters or you have multiple mysql instances running. In this case you can run mysql_install_db with the parameter defaults_file.

Issue on ubuntu with mysql 5.5

On ubuntu 14.04 and with mysql 5.5 I get this error:
Could not open required defaults file: /etc/mysql-1/my.cnf

Stopping apparmor will solve this issue.

Run mysql_install_db again.

Start apparmor again.

Issue on ubuntu with mysql 5.6

I get this error:

There is one file missing under /usr/share/mysql/my-default.cnf. Copy your my.cnf in place of this file.

Output

 

Leave a Reply

Your email address will not be published.