参考文档: http://www.jb51.net/article/77858.htm
# /etc/init.d/mysql stop --停止mysql服务
# /work/program/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking & --按后台进程 以系统用户mysql身份启动服务
# /work/program/mysql/bin/mysql -uroot mysql --系统用户mysql 进入mysql库
mysql> UPDATE user SET authentication_string=password('123qwe') where USER='root'; --修改root用户密码
mysql> FLUSH PRIVILEGES; --刷新权限
mysql> quit --退出
# /etc/init.d/mysql restart --启动服务
# /work/program/mysql/bin/mysql -uroot -p --root用户进入
Enter password: <输入新设的密码newpassword> --输入密码
mysql> alter user 'root'@'localhost' identified by '123'; --再次修改密码才会生效