You are not logged in.

#1 2012-12-02 17:25:55

cool
Member
Registered: 2008-09-12
Posts: 111
Website

[SOLVED] Mysql doesn't start, Can't change dir to '/var/lib/mysql/'

My mysql install was working fine but now it doesn't start

$ mysqld --verbose
121202 22:41:34 [Warning] Can't create test file /var/lib/mysql/home.lower-test
121202 22:41:34 [Warning] Can't create test file /var/lib/mysql/home.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 13)
121202 22:41:34 [ERROR] Aborting

121202 22:41:34 [Note] mysqld: Shutdown complete

I checked using mysql_safe & it seems to be a permission issue

$ mysqld_safe --user=mysql
121202 22:45:34 mysqld_safe Logging to '/var/lib/mysql/home.err'.
121202 22:45:35 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
/usr/bin/mysqld_safe: line 107: /var/lib/mysql/home.err: Permission denied
rm: cannot remove ‘/var/run/mysqld/mysqld.sock’: Permission denied
rm: cannot remove ‘/var/lib/mysql/home.pid’: Permission denied
/usr/bin/mysqld_safe: line 144: /var/lib/mysql/home.err: Permission denied
121202 22:45:35 mysqld_safe mysqld from pid file /var/lib/mysql/home.pid ended
/usr/bin/mysqld_safe: line 107: /var/lib/mysql/home.err: Permission denied

But the thing is /var/lib/mysql is already owned by mysql,

$ ls -la /var/lib/ | grep mysql
drwxrw-r-- 19 mysql   root   4.0K Dec  2 22:29 mysql
$ ls -la /var/ | grep lib
drwxr-xr-x 29 root root  4.0K Nov 28 19:59 lib
$ ls -la / | grep var
drwxr-xr-x  13 root root 4.0K Nov 28 19:58 var

so anyone tell me what permissions I have gotten wrong & how can I get mysql to work again?

Last edited by cool (2012-12-02 18:26:18)

Offline

#2 2012-12-02 17:57:08

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [SOLVED] Mysql doesn't start, Can't change dir to '/var/lib/mysql/'

1. You have to start mysqld as root using either sudo or from your root account
2. The safest way to start mysql is using the unit file (systemd) or service file (rc.d) -- e.g. 'sudo systemctl mysqld start'
3. My /var/lib/mysql directory has the following permissions 700 and owner/group is mysql/mysql. With those permissions, you're not going to be able to view the contents of the directory unless you are root or that user.

Scott

Offline

#3 2012-12-02 18:25:48

cool
Member
Registered: 2008-09-12
Posts: 111
Website

Re: [SOLVED] Mysql doesn't start, Can't change dir to '/var/lib/mysql/'

I was able to solve my problem, thanks for posting this

Offline

#4 2018-03-03 17:31:10

Nasdav
Member
Registered: 2018-03-03
Posts: 1

Re: [SOLVED] Mysql doesn't start, Can't change dir to '/var/lib/mysql/'

Shouldn't he change the permissions?
Since running MySQL as root is not advised

Offline

#5 2018-03-03 17:38:10

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Mysql doesn't start, Can't change dir to '/var/lib/mysql/'

Don't necrobump threads, especially solved ones: https://wiki.archlinux.org/index.php/Co … bumping.22



Closing


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB