-
修改MySQL的配置文件(默认为/etc/my.cnf),在[mysqld]下添加一行skip-grant-tables
-
-
-
-
保存配置文件后,重启MySQL服务 service mysql restart
-
-
再次进入MySQL命令行 mysql -uroot -p,输入密码时直接回车,就会进入MySQL数据库了
-
修改密码
-
mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
-
mysql> flush
privileges
;
mysql> quit;
-
set password=password('A123456');
-
远程
-
mysql>grant all privileges on *.* to root@'%' identified by 'A123456';
mysql> flush privileges;