设置 root 密码,启用 root 用户进行套接字和 http 访问
解决以下问题:用户 root 访问被拒绝使用密码是停止 mySQL:
sudo systemctl stop mysql
重新启动 mySQL,跳过授权表:
sudo mysqld_safe --skip-grant-tables
登录:
mysql -u root
在 SQL shell 中,查看用户是否存在:
select User, password,plugin FROM mysql.user ;
更新用户(所有插件的插件为 null):
update mysql.user set password=PASSWORD('mypassword'), plugin = NULL WHERE User = 'root';
exit;
在 Unix shell 中,在没有授权表的情况下停止 mySQL,然后使用授权表重新启动:
sudo service mysql stop
sudo service mysql start