mysql首次安装登录问题
mysql首次安装,登录的时候出现错误 ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: NO)
perom@perom-CMT:~$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
解决办法
先用root用户登录
perom@perom-CMT:~$ sudo mysql -u root
[sudo] perom 的密码
在sql中执行语句
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set authentication_string=PASSWORD("密码") where User='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> update user set plugin="mysql_native_password" where User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye