mysql root用户密码忘记或者是权限不对。
1. 先停止mysql
  1. sudo service mysql stop

2. 运行mysqld_safe
  1. sudo mysqld_safe --user=mysql --skip-grant-tables --skip-networking

3. 命令行下进入数据库
  1. mysql -u root mysql

4. 修改user表:root用户密码
  1. update user set password=PASSWORD('newpassword') where user='root';

5.修改user表:root权限(Grant_priv),其他权限类似
  1. select * from user where user='root';

  2. update user set Grant_priv='Y' where user='root';

6. 停止mysqld_safe,重启mysql(可能不安全)
  1. kill -9 mysqld_safe_pid

  2. pkill mysql

  3. service mysql start