简体   繁体   中英

MySql : ERROR 1018 (HY000): Can't read dir of '.' (errno: 13)

Recently mysql crashed and I had no choice but to backup the contents of var/lib/mysql to /home/backup/ and re-install the database.

after re-installing mysql server,

  1. renamed /var/lib/mysql to mysql.orig

  2. in /var/lib, I made a directory mysql

  3. moved the contents from the home/backup folder to /var/lib/mysql

Now by running mysql -u user -p and when I call show databases It give s the following error :

MySql : ERROR 1018 (HY000): Can't read dir of '.' (errno: 13)

How to solve this?

You need to set ownership and permissions for directory:

chown -R mysql:mysql /var/lib/mysql/ #your mysql user may have different name

chmod -R 755 /var/lib/mysql/

Note: -R makes commands recursive - you may omit it, if there is no subdirs in /var/lib/mysql/.

Source: mysql error : ERROR 1018 (HY000): Can't read dir of '.' (errno: 13)

For future users. Two more steps are needed: 1. chown -R mysql:mysql /var/lib/mysql/ 2. service mysql restart

And you are done! All your databases are back.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM