如何在Ubuntu 16.04上使用空/空密码设置Mysql

Lei*_*ell 1 mysql passwords

尝试以root用户身份使用空密码登录mysql会导致

access denied for user 'root'@'localhost'

Lei*_*ell 5

首先确保你是root用户,因为非root用户无法使用空密码登录mysql root用户:

$ sudo su

接下来登录mysql

# mysql -uroot

如果这使您拒绝访问,我们需要(重新)设置密码以登录,然后我们可以删除:

# mysql_secure_installation

按照提示操作,然后尝试使用您在上一步中提供的密码再次使用新密码的root用户登录.

# mysql -uroot -p

登录到mysql后:

use mysql; update user set authentication_string=password(''), plugin='mysql_native_password' where user='root'; flush privileges;

现在注销,退出root并登录普通帐户下的mysql root用户:

exit # exit mysql # exit # exit root user back to normal ubuntu user account $ mysql -uroot # log back in to mysql under your non-root ubuntu user account