Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQLd: Can't change dir to '/var/lib/mysql/' (Errcode: 13 - Permission denied)

Tags:

mysql

I am using MySQL Ver 14.14 Distrib 5.7.21, for Linux (x86_64) using EditLine wrapper. I tried to change the directory of sql database in an external hard drive (ext4 format).I tried changing directory in my path to hard drive and symlink /var/lib/mysql. Every time when I try to start MySQL I get the same error:

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Sat 2018-01-27 12:47:34 GMT; 3s ago
  Process: 3042 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 3035 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 3042 (code=exited, status=1/FAILURE);         : 3043 (mysql-systemd-s)
   CGroup: /system.slice/mysql.service
           └─control
             ├─3043 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─3052 sleep 1

Jan 27 12:47:34 Lighter mysqld[3042]: mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13 - Permission denied)
Jan 27 12:47:34 Lighter mysqld[3042]: 2018-01-27T12:47:34.048213Z 0 [Warning] Changed limits: max_open_files: 1024 (r
Jan 27 12:47:34 Lighter mysqld[3042]: 2018-01-27T12:47:34.048251Z 0 [Warning] Changed limits: table_open_cache: 431 (
Jan 27 12:47:34 Lighter mysqld[3042]: 2018-01-27T12:47:34.183417Z 0 [Warning] TIMESTAMP with implicit DEFAULT value i
Jan 27 12:47:34 Lighter mysqld[3042]: 2018-01-27T12:47:34.183465Z 0 [Warning] Can't create test file /var/lib/mysql/L
Jan 27 12:47:34 Lighter mysqld[3042]: 2018-01-27T12:47:34.183483Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.21-0ubuntu0.1
Jan 27 12:47:34 Lighter mysqld[3042]: 2018-01-27T12:47:34.185214Z 0 [Warning] Can't create test file /var/lib/mysql/L
Jan 27 12:47:34 Lighter mysqld[3042]: 2018-01-27T12:47:34.185225Z 0 [Warning] Can't create test file /var/lib/mysql/L
Jan 27 12:47:34 Lighter mysqld[3042]: 2018-01-27T12:47:34.185484Z 0 [ERROR] failed to set datadir to /var/lib/mysql/
Jan 27 12:47:34 Lighter systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
like image 955
AleRodi Avatar asked Nov 07 '22 11:11

AleRodi


1 Answers

For the Errcode13 Permission denied 1.check your /var/lib/mysql user and authority in each directory, e.g.,/var,/var/lib,/var/lib/mysql

2.check your SElinux status

like image 161
IanChan Avatar answered Nov 14 '22 21:11

IanChan