MySQL UNIX 套接字文件的 mysqld_safe 目录“/var/run/mysqld”不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42153059/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 22:11:52  来源:igfitidea点击:

mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists

mysqlsockets

提问by Rajadip

While starting mysql server 5.7.17 using mysqld_safe, following error occcours.

使用 mysqld_safe 启动 mysql server 5.7.17 时,出现以下错误。

2017-02-10T17:05:44.870970Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-02-10T17:05:44.872874Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-02-10T17:05:44.874547Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

How to fix it ?

如何解决?

回答by Matt Clark

It seems odd that this directory was not created at install - have you manually changed the path of the socket file in the my.cfg?

这个目录不是在安装时创建的,这似乎很奇怪 - 您是否手动更改了 my.cfg 中套接字文件的路径?

Have you tried simply creating this directory yourself, and restarting the service?

您是否尝试过自己创建此目录并重新启动服务?

mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld

回答by Partha Sen

When I used the code mysqld_safe --skip-grant-tables &but I get the error:

当我使用代码mysqld_safe --skip-grant-tables &但出现错误时:

mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.

UNIX 套接字文件的 mysqld_safe 目录“/var/run/mysqld”不存在。

$ systemctl stop  mysql.service
$ ps -eaf|grep mysql
$ mysqld_safe --skip-grant-tables &

I solved:

我解决了:

$ mkdir -p /var/run/mysqld
$ chown mysql:mysql /var/run/mysqld

Now I use the same code mysqld_safe --skip-grant-tables &and get

现在我使用相同的代码mysqld_safe --skip-grant-tables &并得到

mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

mysqld_safe 使用 /var/lib/mysql 中的数据库启动 mysqld 守护进程

If I use $ mysql -u rootI'll get :

如果我使用$ mysql -u root我会得到:

Server version: 5.7.18-0ubuntu0.16.04.1 (Ubuntu)

服务器版本:5.7.18-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

版权所有 (c) 2000, 2017,Oracle 和/或其附属公司。版权所有。

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Oracle 是 Oracle Corporation 和/或其附属公司的注册商标。其他名称可能是其各自所有者的商标。

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

输入“帮助;” 或 '\h' 寻求帮助。键入 '\c' 清除当前输入语句。

mysql>

mysql>

Now time to change password:

现在是时候更改密码了:

mysql> use mysql
mysql> describe user;

Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A

读取表信息以完成表名和列名您可以关闭此功能以使用 -A 更快地启动

Database changed

数据库已更改

mysql> FLUSH PRIVILEGES;
mysql> SET PASSWORD FOR root@'localhost' = PASSWORD('newpwd');

or If you have a mysql root account that can connect from everywhere, you should also do:

或者如果您有一个可以从任何地方连接的 mysql root 帐户,您还应该执行以下操作:

UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';

Alternate Method:

替代方法:

   USE mysql
   UPDATE user SET Password = PASSWORD('newpwd')
   WHERE Host = 'localhost' AND User = 'root';

And if you have a root account that can access from everywhere:

如果您有一个可以从任何地方访问的 root 帐户:

 USE mysql
 UPDATE user SET Password = PASSWORD('newpwd')
 WHERE Host = '%' AND User = 'root';`enter code here

now need to quitfrom mysql and stop/start

现在需要quit从 mysql 和停止/启动

FLUSH PRIVILEGES;
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start

now again ` mysql -u root -p' and use the new password to get

现在再次`mysql -u root -p'并使用新密码获取

mysql>

mysql>

回答by Heli Perez

Work for me in CentOS:

在 CentOS 中为我​​工作:

$ service mysql stop
$ mysqld --skip-grant-tables &
$ mysql -u root mysql

mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

$ service mysql restart

回答by David Baldwin

You may try the following if your database does not have any data OR you have another away to restore that data. You will need to know the Ubuntu server root password but not the mysql root password.

如果您的数据库没有任何数据或者您有另一个可以恢复该数据,您可以尝试以下操作。您需要知道 Ubuntu 服务器的 root 密码,但不需要知道 mysql 的 root 密码。

It is highly probably that many of us have installed "mysql_secure_installation" as this is a best practice. Navigate to bin directory where mysql_secure_installation exist. It can be found in the /bin directory on Ubuntu systems. By rerunning the installer, you will be prompted about whether to change root database password.

我们中的许多人很可能已经安装了“mysql_secure_installation”,因为这是最佳实践。导航到 mysql_secure_installation 所在的 bin 目录。它可以在 Ubuntu 系统的 /bin 目录中找到。通过重新运行安装程序,系统会提示您是否更改 root 数据库密码。