导致这个错误的原因:
因为安装系统时设置了hostname为localhost导致mysql在创建表的时候没有创建成功。因此mysql库中user表里没有root这个用户或者说root没有显示出来,无法查看root的状态。这时需要手动创建。然而在安全模式无法直接创建用户,错误见下。
变个方向就能创建了,先给root给予权限,然后刷新表。之后就可以创建了。
一、killall -TERM mysqld
以安全模式启动mysql
/usr/bin/mysqld_safe --skip-grant-tables &
进入mysql
/usr/bin/mysql
mysql> use mysql
Database changed
mysql> select * from user where user='root';
Empty set (0.00 sec)
mysql> grant all privileges on *.* to root@localhost identified by 'linuxtone' with GRANT OPTION;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute
this statement
mysql> update user set password=password('linuxtone') where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
注意单双引号。
mysql> flush privileges; //注意先刷新下表
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to root@localhost identified by 'linuxtone' with GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from user where user='root';
后期处理:
/usr/bin/mysqladmin shutdown -uroot -p
刚才的密码
然后正常启动:/usr/bin/mysqld_safe &
/usr/bin/mysql -uroot -p
能正常登录!
因为安装系统时设置了hostname为localhost导致mysql在创建表的时候没有创建成功。因此mysql库中user表里没有root这个用户或者说root没有显示出来,无法查看root的状态。这时需要手动创建。然而在安全模式无法直接创建用户,错误见下。
变个方向就能创建了,先给root给予权限,然后刷新表。之后就可以创建了。
一、killall -TERM mysqld
以安全模式启动mysql
/usr/bin/mysqld_safe --skip-grant-tables &
进入mysql
/usr/bin/mysql
mysql> use mysql
Database changed
mysql> select * from user where user='root';
Empty set (0.00 sec)
mysql> grant all privileges on *.* to root@localhost identified by 'linuxtone' with GRANT OPTION;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute
this statement
mysql> update user set password=password('linuxtone') where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
注意单双引号。
mysql> flush privileges; //注意先刷新下表
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to root@localhost identified by 'linuxtone' with GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from user where user='root';
后期处理:
/usr/bin/mysqladmin shutdown -uroot -p
刚才的密码
然后正常启动:/usr/bin/mysqld_safe &
/usr/bin/mysql -uroot -p
能正常登录!