Re-creating MySQL data directory

If you ever need to re-create the data directory for MySQL, type this:

sudo mysql_install_db

However, if mysql does not start up again, check the log (usually at /var/lib/mysql/$HOSTNAME.err). Maybe it shows something like:

/usr/sbin/mysqld: Can’t find file: ‘./mysql/plugin.frm’ (errno: 13)
[ERROR] Can’t open the mysql.plugin table. Please run mysql_upgrade to create it.

The (errno: 13) is a permissions thing. So do this:

sudo chown -R mysql:mysql /var/lib/mysql

Now try to start mysql.


mysql

73 Words

2010-07-19 16:57 +0000