mysqladmin:连接到"localhost"服务器失败 [英] mysqladmin: connect to server at 'localhost' failed
问题描述
今天(2015-05-02)我通过apt-get update和
升级了Linux系统.
apt-get升级,而mysql,mysqladmin和更多软件包
已更新. mysql-server-5.5运行,我可以登录并全部执行
典型的数据库操作,但是当我键入以下内容时:
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:
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)'
以前,我可以通过简单地将mysql根密码设置为new来解决此问题.
这不再解决问题:
Formerly I could solve this issue by simple setting the mysql root password new.
This does not solve the issue anymore:
user@ubuntu:~# sudo dpkg-reconfigure mysql-server-5.5
如何在不重新安装mysql的情况下再次启动mysqladmin?
How do I get the mysqladmin up again without reinstalling mysql?
推荐答案
短版:如果您的MySQL用户root
需要密码才能连接,最好使用
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
似乎需要密码才能连接
Longer version: Your MySQL user root
seems to need a password to connect
设置新的mysql根密码
setting the mysql root password new
但是mysqladmin
尝试在没有密码的情况下连接
But mysqladmin
tries to connect without a password
拒绝访问用户'root'@'localhost'(使用密码:否)'
'Access denied for user 'root'@'localhost' (using password: NO)'
mysqladmin
这样做是因为您没有告诉其他人;)
And mysqladmin
does that because you're not telling it otherwise ;)
mysqladmin
与其他与MySQL相关的命令行工具(mysql
,mysqldump
,mysqlshow
等)一样,提供了提供此类访问数据的选项.
mysqladmin
, like other MySQL-related command line tools (mysql
, mysqldump
, mysqlshow
etc.), offers options to provide such access data.
-
h
:要连接到的主机.如果未提供,则假定为localhost
-
u
:以哪个用户身份连接.如果未提供,则假定为root
-
p
:要使用的密码.如果未提供,则不使用密码
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
您应该可以使用类似的东西
You should be able to use something like
mysqladmin -uroot -pmysupersecretpassword proc
(请注意,选项及其值之间没有空格).您也可以让MySQL要求您输入密码,例如
(be aware that there's no space between the options and their values). You can also have MySQL ask you for the password like
mysqladmin -uroot -p proc
这样,MySQL应该提示您输入密码.
With that, MySQL should give you a prompt where you can enter your password.
这篇关于mysqladmin:连接到"localhost"服务器失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!