MySQL mysqladmin:连接到“本地主机”服务器失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30004588/
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
mysqladmin: connect to server at 'localhost' failed
提问by udgru
Today (2015-05-02) I upgraded my Linux system via apt-get update and
apt-get upgrade whereas mysql, mysqladmin and a lot more packages
have been updated. The mysql-server-5.5 runs and I can login and do all
the typical database operations but when I type:
今天 (2015-05-02) 我通过 apt-get update 和
apt-get upgrade升级了我的 Linux 系统,而 mysql、mysqladmin 和更多的包
已经更新。mysql-server-5.5 运行,我可以登录并执行所有
典型的数据库操作,但是当我输入:
user@ubuntu:~# mysqladmin proc
I get the following error:
我收到以下错误:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
Formerly I could solve this issue by simple setting the mysql root password new.
This does not solve the issue anymore:
以前我可以通过简单地将 mysql root 密码设置为新来解决这个问题。
这不再解决问题:
user@ubuntu:~# sudo dpkg-reconfigure mysql-server-5.5
How do I get the mysqladmin up again without reinstalling mysql?
如何在不重新安装 mysql 的情况下再次启动 mysqladmin?
回答by Henning Kockerbeck
Short version: If your MySQL user root
needs a password to connect, it might be a good idea to have mysqladmin
provide that password ;)
简短版本:如果您的 MySQL 用户root
需要密码才能连接,mysqladmin
提供该密码可能是个好主意;)
Longer version: Your MySQL user root
seems to need a password to connect
更长的版本:您的 MySQL 用户root
似乎需要密码才能连接
setting the mysql root password new
设置mysql root密码新
But mysqladmin
tries to connect withouta password
但是mysqladmin
尝试在没有密码的情况下连接
'Access denied for user 'root'@'localhost' (using password: NO)'
'用户'root'@'localhost'的访问被拒绝(使用密码:NO)'
And mysqladmin
does that because you're not telling it otherwise ;)
而mysqladmin
这是否因为你不告诉它,否则;)
mysqladmin
, like other MySQL-related command line tools (mysql
, mysqldump
, mysqlshow
etc.), offers options to provide such access data.
mysqladmin
像其他MySQL相关的命令行工具(mysql
,mysqldump
,mysqlshow
等),提供选项,以提供这样的访问数据。
h
: Which host to connect to. If not provided,localhost
is assumedu
: Which user to connect as. If not provided,root
is assumedp
: Which password to use. If not provided, no password is used
h
: 连接到哪个主机。如果未提供,localhost
则假定u
: 以哪个用户身份连接。如果未提供,root
则假定p
: 使用哪个密码。如果未提供,则不使用密码
You should be able to use something like
你应该能够使用类似的东西
mysqladmin -uroot -pmysupersecretpassword proc
(be aware that there's no space between the options and their values). You can also have MySQL ask you for the password like
(请注意,选项与其值之间没有空格)。您也可以让 MySQL 询问您的密码,例如
mysqladmin -uroot -p proc
With that, MySQL should give you a prompt where you can enter your password.
这样,MySQL 应该会提示您输入密码。