简体   繁体   English

如何在不输入root密码的情况下登录mysql?

[英]How can I log in to mysql without typing the root password?

For the last few years I logged in to my local mysql database by simply typing mysql on Terminal.在过去的几年里,我通过在终端上简单地输入mysql登录到我的本地 mysql 数据库。 But now, for some reasons I found that this doesn't work right now, with the access denied error:但是现在,由于某些原因,我发现这现在不起作用,出现访问被拒绝错误:

ERROR 1045 (28000): Access denied for user 'me'@'localhost' (using password: NO)错误 1045 (28000):用户“我”@“本地主机”的访问被拒绝(使用密码:否)

Now I must log in to type the following:现在我必须登录才能输入以下内容:

mysql -uroot -proot

This is quite painstaking, so I rather want to swich back to when I just type in mysql to log in to the database.这很辛苦,所以我宁愿切换回我只输入mysql登录数据库的时候。

I don't set it as an alias in my zsh shell, but I cannot remember how I set it way before, such that I don't need to type in my user and password.我没有在我的 zsh shell 中将它设置为别名,但我不记得我以前是如何设置的,这样我就不需要输入我的用户名和密码。

So how can I set it such that I log in with mysql command only?那么如何设置它以便我仅使用mysql命令登录? I use Mojave beta.我使用莫哈韦测试版。

我认为您当前的连接已设置密码,尝试使用 null 创建新连接或在询问密码时将其留空 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM