mysqladmin: connect to server at 'localhost' failed

余生颓废 提交于 2019-12-04 03:09:43

Short version: If your MySQL user root needs a password to connect, it might be a good idea to have mysqladmin provide that password ;)

Longer version: Your MySQL user root seems to need a password to connect

setting the mysql root password new

But mysqladmin tries to connect without a password

'Access denied for user 'root'@'localhost' (using password: NO)'

And mysqladmin does that because you're not telling it otherwise ;)

mysqladmin, like other MySQL-related command line tools (mysql, mysqldump, mysqlshow etc.), offers options to provide such access data.

  • h: Which host to connect to. If not provided, localhost is assumed
  • u: Which user to connect as. If not provided, root is assumed
  • p: Which password to use. If not provided, no password is used

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

mysqladmin -uroot -p proc

With that, MySQL should give you a prompt where you can enter your password.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!