想要更改mysql root的密码,但出现错误

发布于 2024-10-20 19:39:46 字数 452 浏览 2 评论 0原文

我使用 macports 安装 Mysql5。但是,当尝试为 root 帐户创建密码时,我收到此错误:

sh-3.2# /opt/local/lib/mysql5/bin/mysqladmin  -u root password 123456
/opt/local/lib/mysql5/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (61)'
Check that mysqld is running and that the socket: '/opt/local/var/run/mysql5/mysqld.sock' exists!

如何解决此问题?

I install Mysql5 using macports. But when trying to create password for the root account, I got this error:

sh-3.2# /opt/local/lib/mysql5/bin/mysqladmin  -u root password 123456
/opt/local/lib/mysql5/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (61)'
Check that mysqld is running and that the socket: '/opt/local/var/run/mysql5/mysqld.sock' exists!

How to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

静水深流 2024-10-27 19:39:46

检查 mysql 守护进程是否正在运行

ps aux | grep mysqld

如果是,您应该看到类似以下内容:

mysql    28290  1.1  2.7 340496 56812 ?        Sl   Jul31 348:27 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --socket=/var/lib/mysql/mysql.sock

如果幸运的话,您将看到 --socket 参数准确指定套接字文件所在的位置。如果它与 mysql 客户端正在查找的路径 (/opt/local/var/run/mysql5/mysqld.sock) 不同,那么您可以手动将其指定为命令行参数之一。

另外,您应该检查 /etc/my.cnf 是否存在并且设置正确,这里是 my.cnf 的示例:

[mysqld]
user=mysql_owner
datadir=/path/to/datadir/mysql
socket=/path/to/datadir/mysql/mysql.sock
skip-innodb

[mysql.server]
user=mysql_owner
basedir=/path/to/datadir

[client]
user=mysql_owner
socket=/path/to/datadir/mysql/mysql.sock

[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

希望这有帮助,如果您仍然遇到问题,请消除疑问

Check to see if the mysql daemon is running

ps aux | grep mysqld

If it is you should see something like:

mysql    28290  1.1  2.7 340496 56812 ?        Sl   Jul31 348:27 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --socket=/var/lib/mysql/mysql.sock

If you are lucky you will see the --socket argument specifying exactly where your socket file is located. If it is somewhere different than the path your mysql client is looking for (/opt/local/var/run/mysql5/mysqld.sock), then you can specify it manually as one of the command line arguments.

Also, you should check to see if /etc/my.cnf exists and is setup properly, here is an example my.cnf:

[mysqld]
user=mysql_owner
datadir=/path/to/datadir/mysql
socket=/path/to/datadir/mysql/mysql.sock
skip-innodb

[mysql.server]
user=mysql_owner
basedir=/path/to/datadir

[client]
user=mysql_owner
socket=/path/to/datadir/mysql/mysql.sock

[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Hope this helps, fire away with questions if you are still having issues

多情癖 2024-10-27 19:39:46

检查您的发行版的默认套接字是什么。您还可以尝试使用 TCP4 上的连接:

/opt/local/lib/mysql5/bin/mysqladmin -h 127.0.0.1 -u root -p secret

或者,如果您找到了套接字的路径(在 mysql 的配置文件中),您可以使用类似以下内容的内容:

/opt/local/lib/mysql5/bin/mysqladmin --socket=/tmp/mysql.sock -u root -p secret

Check what is the default socket for your distribution. You can also try connectiong on TCP4 using:

/opt/local/lib/mysql5/bin/mysqladmin -h 127.0.0.1 -u root -p secret

Or if you have found the path to your socket (in mysql's config file) you can use somthing like:

/opt/local/lib/mysql5/bin/mysqladmin --socket=/tmp/mysql.sock -u root -p secret
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文