1、登录MySQL数据库(mysql -hlocalhost -uroot -p)
mysql -hlocalhost -uroot -p
-h数据库主机
-u用户
-p密码
-P端口号(大写P)
例如:mysql -h127.0.0.1 -uroot -p123456 -P3306
2.修改密码
修改mysql数据库的user表格,如
update user set Password=password("123456") where Host='127.0.0.1';
然后重启数据库
service mysql restart