mysql var/lib/mysql 目录不存在,无法启动mysql服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16890154/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql var/lib/mysql directory doesn't exist, can't start mysql server
提问by almel
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
我已经阅读了许多论坛帖子,并希望解决我在让自己的 mysql 服务器启动和正常工作时遇到的问题,但到目前为止都没有奏效。我读过的许多论坛帖子都引用了 /var/lib/mysql 文件夹,我收到的一些错误也是如此,例如当我运行时
$ mysqld
on Terminal using a Mac and receive the following error
在使用 Mac 的终端上并收到以下错误
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 下载页面的 dmg 文件和解压缩的 tar.gz 文件中删除了与 MySQL 相关的所有内容并重新安装了 MySQL。没有任何效果。奇怪的是,几天前我还在使用 MySQL 和 MySQL Workbench,当我运行以下命令时它突然开始给我这个错误
$ 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.
我什至无法使用 mysqld_safe 启动守护进程...我需要从这里开始演练如何让 MySQL 服务器再次正确运行。
回答by maaartinus
On a fresh Ubuntu 16, after having done some nonsense, I removed /var/lib/mysql manually. I wanted mariadb and hoped that
在新的 Ubuntu 16 上,在做了一些废话之后,我手动删除了 /var/lib/mysql。我想要 mariadb 并希望
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).
因为这个公共包似乎负责目录创建。这花了我比需要的更长的时间,因为它是我没有明确安装的包,所以我没有考虑删除它(一些 autoremove 可能会有所帮助)。
回答by Vorsprung
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
我猜你正在以用户“mysql”的身份运行 mysql。如果没有,请创建用户mysql
并使用选项 --user="mysql" 运行 mysqld_safe 或 chown 由您正在运行的用户拥有的文件夹