mysql部分用户无权限导致无法创建数据库

Posted in 2016-12-25 8:4 | Category: Linux | Tags: linux mysql

记一下

如果记得root用户名及密码

mysql -u root -pyoupassword

如果忘记root用户名及密码

以safe模式启动

mysqld_safe --skip-grant-tables &
mysql -u root

修改user权限

mysql> use mysql;
mysql> show grants;

mysql> GRANT ALL PRIVILEGES ON *.* TO 'youruser'@'%';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

# 这里应该有些问题 maybe set global read_only=OFF/ON;
mysql> set global read_only=0;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

# 权限给的太大了
mysql> GRANT ALL PRIVILEGES ON *.* TO 'youruser'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> set global read_only=1;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye