[ERROR] /usr/sbin/mysqld: Can’t find file: ‘./mysql/host.frm’ (errno: 13)

[ERROR] /usr/sbin/mysqld: Can’t find file: ‘./mysql/host.frm’ (errno: 13)

[ERROR] Fatal error: Can’t open and lock privilege tables: Can’t find file: ‘./mysql/host.frm’ (errno: 13)

 

We usually see above errors while we’re trying to start an additional MySQL instances on the same server. But we won’t see it with a fresh installation.

To solve this we need to follow below procedure.

 

Step 1: Copy all the old data files to your new database directory; we can remove the databases which are not required – ideally we should copy mysql folder which has meta data like host, time frms… etc

cp /var/lib/mysql/datafiles/* <new datadir> -R

 

Step 2: Change permission as below.

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

 

Step 3: Make sure you use the old socket in the /etc/my.cnf

socket          = /var/lib/mysql/mysql.sock

 

Step 4: stop the existing mysql instances if any & start the new one as below.

 

/usr/bin/mysqld_safe & <OR>

 

/usr/bin/mysqld_safe –defaults-file = /etc/my.cnf_newone &

 

–defaults-file=FILE       Use the specified defaults file

 

 

if the existing setup had a authentication enabled, you can skip it by keeping below parameter in my.cnf & then you can connect to root without password.

 

[mysqld]

skip-grant-tables

 

  • Ask Question