服务器之家:专注于服务器技术及软件下载分享
分类导航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|

服务器之家 - 数据库 - Mysql - ubuntu系统中Mysql ERROR 1045 (28000): Access denied for user root@ localhost问题的解决方法

ubuntu系统中Mysql ERROR 1045 (28000): Access denied for user root@ localhost问题的解决方法

2020-07-29 17:14Agoly Mysql

这篇文章主要介绍了ubuntu系统安装mysql登陆提示 解决Mysql ERROR 1045 (28000): Access denied for user root@ localhost问题,需要的朋友可以参考下

ubuntu系统中Mysql ERROR 1045 (28000): Access denied for user root@ localhost问题的解决方法

第一种方式:

skip-grant-tables:非常有用的mysql启动参数

介绍一个非常有用的mysql启动参数—— --skip-grant-tables。顾名思义,就是在启动
mysql时不启动grant-tables,授权表。有什么用呢?当然是忘记管理员密码后有用。

以命令行参数启动mysql:# /usr/bin/mysqld_safe --skip-grant-tables &

3、修改管理员密码:

use mysql;

update user set password=password('yournewpasswordhere') where user='root'; flush privileges; exit;

4、杀死mysql,重启mysql.

然后就可以直接登录

方法2:

查看mysql安装的路径

ubuntu系统中Mysql ERROR 1045 (28000): Access denied for user root@ localhost问题的解决方法

然后我们更改root用户的密码,

查看默认密码先

ubuntu系统中Mysql ERROR 1045 (28000): Access denied for user root@ localhost问题的解决方法

然后直接登录

ubuntu系统中Mysql ERROR 1045 (28000): Access denied for user root@ localhost问题的解决方法

然后再更改root默认用户名和密码

?
1
2
GRANT ALL PRIVILEGES on *.* to 'root'@'localhost' identified by '密码';
flush privileges;

  mysql>update mysql.user set password=password('新密码') where User="test" and Host="localhost";

  mysql>flush privileges;

ubuntu系统中Mysql ERROR 1045 (28000): Access denied for user root@ localhost问题的解决方法

  mysql>delete from user where User='root' and Host='localhost';

  mysql>flush privileges;

mysql>grant select,delete,update,create,drop on *.* to test@"%" identified by "1234";

mysql> UPDATE user SET Host='127.0.0.1' WHERE User='root' AND Host='localhost';

mysql> flush privileges;

ubuntu系统中Mysql ERROR 1045 (28000): Access denied for user root@ localhost问题的解决方法

把Grant_priv修改为‘Y'即可(flush privileges;(执行该语句或重启MySQL后生效)),update mysql.user set Grant_priv='Y' where user='ptmind';

延伸 · 阅读

精彩推荐