今天在启动mysql时出现以下问题:
[root@www ~]# mysql -u root -p enter password: error 1045 (28000): access denied for user 'root'@'localhost' (using password: yes)
网上的答案是各种各样的,最终解决问题的方法总结为以下,好多都是没有设置初始密码造成此问题的。
解决方法如下:
[root@www ~]# service mysqld stop #先关闭mysql服务 stopping mysqld: [ ok ] [root@www ~]# mysql error 2002 (hy000): can't connect to local mysql server through socket '/var/lib/mysql/mysql.sock' (2) [root@www ~]# mysql -u root -p #关闭服务后又出现如下问题 enter password: error 2002 (hy000): can't connect to local mysql server through socket '/var/lib/mysql/mysql.sock' (2) [root@www ~]# mysql -u root mysql #键入此命令进入mysql reading table information for completion of table and column names you can turn off this feature to get a quicker startup with -a welcome to the mysql monitor. commands end with ; or \g. your mysql connection id is 1 server version: 5.1.73 source distribution copyright (c) 2000, 2013, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or its affiliates. other names may be trademarks of their respective owners. type 'help;' or '\h' for help. type '\c' to clear the current input statement. mysql> update user set password=password('123') where user='root' and host='localhost'; ---->修改root的密码 query ok, 1 row affected (0.04 sec) rows matched: 1 changed: 1 warnings: 0 mysql> flush priviledge; error 1064 (42000): you have an error in your sql syntax; check the manual that corresponds to your mysql server version for the right syntax to use near 'priviledge' at line 1 mysql> flush privileges; query ok, 0 rows affected (0.00 sec) mysql> \q bye [root@www ~]# mysql -u root -p ------>重新进入 enter password: welcome to the mysql monitor. commands end with ; or \g. your mysql connection id is 2 server version: 5.1.73 source distribution copyright (c) 2000, 2013, oracle and/or its affiliates. all rights reserved. oracle is a registered trademark of oracle corporation and/or its affiliates. other names may be trademarks of their respective owners. type 'help;' or '\h' for help. type '\c' to clear the current input statement. mysql> \q bye
到此就完了!!
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
小白安装登录mysql-8.0.19-winx64的教程图解(新手必看)
Navicat连接MySQL时报10060、1045错误及my.ini位置问题
网友评论