当你安装好mysql后,发现mysql -u root -p
直接按俩次enter竟然不用密码就能登录进去,可是navicat连接mysql需要密码啊。怎么办?
于是我通过百度寻觅良久发现多数都是通过下面的命令修改。但是自己执行时报下面的错。
mysql> set password for root@localhost = password('123456'); 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 'passw ord('123456')' at line 1
后来我通过下面的命令成功修改了密码。SET PASSWORD FOR root@localhost = '123456';
mysql> SET PASSWORD FOR root@localhost = '123456'; Query OK, 0 rows affected (0.04 sec)
修改成功。
来源:https://www.cnblogs.com/jing-tian/p/12231780.html