我发现了一个错误:
root@sys3026:/home/sys3026# mysql --user=root --password
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)任何人请帮帮我。提前谢谢..。
发布于 2019-03-28 19:45:02
当MySQL用户被配置为使用auth_socket (而不是mysql_native_password) (在Ubuntu18.04中默认情况下)时,您可以以以下方式以root身份登录:
sudo mysql -u'root'或者只是:
sudo mysql参考文献:
发布于 2017-05-16 10:41:24
如果您忘记密码或无法登录,您可以始终在"safe_mode“中运行mysql。它允许您不受任何密码限制地访问它--更改根密码或在发生错误时调整其他内容。
systemctl stop mysql
sudo mysqld_safe --skip-grant-tables &现在,您可以不使用密码访问mysql服务器。
mysql -uroot在mysql shell中向根用户添加一个新密码
use mysql;
update user set password=PASSWORD("newpassword") where User='root';
flush privileges;现在,在正常模式下重新启动它,它将与新密码一起工作。
systemctl stop mysql
systemctl start mysql发布于 2017-05-16 11:12:22
如果数据库没有密码,只需省略--password参数即可。
$ mysql --user=root参考资料:
https://askubuntu.com/questions/915585
复制相似问题