1.执行命令以安全模式启动MySQL
cd /usr/local/mysql/bin sudo ./mysqld_safe --skip-grant-tables
2.同上面目录下执行
update mysql.user set authentication_string=PASSWORD('123') where User='root'; -- 注意 括号旁边转义符号不能少,不然报错如下 -bash: syntax error near unexpected token `('