Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql var/lib/mysql directory doesn't exist, can't start mysql server

Tags:

path

mysql

I have read many a forum post and hopeful solution to the problem I am having with getting my own mysql server to start and work properly, but none so far have worked. Many of the forum posts I've read make reference to a /var/lib/mysql folder, as do some of the errors I receive, such as when I run

$ mysqld

on Terminal using a Mac and receive the following error

2013-06-03 00:40:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-06-03 00:40:46 1851 [Warning] Can't create test file /var/lib/mysql/Alexs-MacBook-Pro-3.lower-test
2013-06-03 00:40:46 1851 [Warning] Can't create test file /var/lib/mysql/Alexs-MacBook-Pro-3.lower-test
mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 2 - No such file or directory)
2013-06-03 00:40:46 1851 [ERROR] Aborting

2013-06-03 00:40:46 1851 [Note] Binlog end
2013-06-03 00:40:46 1851 [Note] mysqld: Shutdown complete

I have deleted everything related to MySQL and reinstalled MySQL, both from a dmg file and from an unzipped tar.gz file from the MySQL downloads page. Nothing has worked. The strange this is that I was using MySQL and the MySQL Workbench only days ago, when suddenly it started giving me this error when I ran the following command

$ mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I can't even start the daemon using mysqld_safe... I need a walkthrough of what to do from here to get the MySQL server correctly running again.

like image 910
almel Avatar asked Jun 03 '13 04:06

almel


2 Answers

On a fresh Ubuntu 16, after having done some nonsense, I removed /var/lib/mysql manually. I wanted mariadb and hoped that

sudo apt-get remove mariadb-server mariadb-client

followed by

sudo apt-get install mariadb-server mariadb-client

re-creates it, but it didn't.

What helped was

sudo apt-get remove mysql-common

as this common package seems to be responsible for the directory creation. This took me much longer than needed, as it's package I didn't install explicitly, so I didn't think about removing it (some autoremove could have helped).

like image 187
maaartinus Avatar answered Oct 23 '22 09:10

maaartinus


I'd try this.

mkdir /var/lib/mysql
chown -R mysql /var/lib/mysql

I am guessing that you are running mysql as the user "mysql". If not, either create the user mysql and run the mysqld_safe with the option --user="mysql" OR chown the folders to be owned by the user you are running as

like image 33
Vorsprung Avatar answered Oct 23 '22 10:10

Vorsprung