linux系统mysql
1,在Linux,先进入/etc,修改my.cnf,任意一行加上"skip-grant-tables"。linux
2,重启MySQL:service mysqld restartsql
3,use mysql;windows
update mysql.user set authentication_string=password('your new password') where user='root';spa
4,flush privileges;命令行
windows系统rest
版本是5.7blog
一、默认安装地址:C:\ProgramData\MySQL\MySQL Server 5.7ip
二、打开my.ini,在mysqld下面加上 skip-grant-tablesstring
表示不用密码就能够登陆。
三、打开电脑的服务,重启MySQL服务。
四、进入MySQL命令行
不用输入密码,直接进入
五、use mysql;
update mysql.user set authentication_string=password('your new password') where user='root';
flush privileges;
六、再回到my.ini,给skip-grant-tables加上“#”,表示注释掉。
七、重启MySQL服务,便可。