Linux解决MySQL登录ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor)问题

问题描述:

下载完mysql之后想要设置密码,输入/usr/bin/mysqladmin -u root -p '123456'之后出现了如下错误:
Linux解决MySQL登录ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor)问题

解决方案:

方式一:免密登录MySQL

然后再次进入到终端当中,敲入 mysql -u root -p命令然后回车,当需要输入密码时,直接按enter键,便可以不用密码登录到数据库当中 , 如图所示 :
Linux解决MySQL登录ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor)问题输入:
mysql>UPDATE mysql.user SET Password=PASSWORD('新密码')where USER='root' ;
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
退出后重启即可用新密码登录MySQL.
Linux解决MySQL登录ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor)问题

方式二:跳过输入密码步骤

1、用命令编辑/etc/my.cnf配置文件,
即:vim /etc/my.cnf

2.在[mysqld]段下添加skip-grant-tables,然后保存并退出