修改mysql登录密码--解决能登录linux却不知道mysql密码
2013-10-29 18:00
302 查看
遇到了烂尾机器的时候,能登录linux却不能登录mysql:
mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
mysql -u root -p
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
此时,如果 MySQL 正在运行,首先杀之: killall -TERM mysqld
然后直接启动/usr/bin/mysqld_safe --skip-grant-tables &
此时就可以直接输入mysql登录了,
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.14 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=password("root") where user="root";
Query OK, 4 rows affected (0.68 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> flush privileges
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql>
再次执行killall -TERM mysqld
然后启动 service mysql start
之后 mysql -uroot -p 使用 root就能登录了。
登录之后又报了个错误:
mysql> use mysql
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
,执行SET PASSWORD = PASSWORD('root');后,正常
mysql> SET PASSWORD = PASSWORD('root');
Query OK, 0 rows affected (0.19 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
mysql -u root -p
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
此时,如果 MySQL 正在运行,首先杀之: killall -TERM mysqld
然后直接启动/usr/bin/mysqld_safe --skip-grant-tables &
此时就可以直接输入mysql登录了,
$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.14 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set password=password("root") where user="root";
Query OK, 4 rows affected (0.68 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> flush privileges
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql>
再次执行killall -TERM mysqld
然后启动 service mysql start
之后 mysql -uroot -p 使用 root就能登录了。
登录之后又报了个错误:
mysql> use mysql
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
,执行SET PASSWORD = PASSWORD('root');后,正常
mysql> SET PASSWORD = PASSWORD('root');
Query OK, 0 rows affected (0.19 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
相关文章推荐
- 在Linux环境下mysql的root密码忘记解决方法 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库。 2.修改MySQL的登录设置: # vi /etc/my.c
- Linux下修改MySQL初始密码、开启远程登录、授权远程登录用户
- linux下mysql的root修改密码忘记解决方法
- linux下mysql的root修改密码忘记解决方法
- linux中mysql安装后,登录提示密码错误,解决办法
- linux下mysql 使用mysql -uroot -p输入密码无法登录问题的解决
- Linux下rpm方式安装mysql(密码修改,远程登录)
- Linux/Mac MySQL忘记密码,命令行修改(已解决)
- linux -- Ubuntu查看修改mysql的登录名和密码、安装phpmyadmin
- linux忘记密码或错误修改/etc/inittab导致无法登录后解决方法
- 【札记】Linux下 MySQL-5.7.17 tar.gz 包方式安装部署后出现密码过期的问题解决(不修改/etc/my.cnf文件)
- linux下修改mysql登录密码
- linux使用mysql(卸载,安装,修改密码,远程登录)
- MySQL安装、密码修改、远程登录、解决看不到mysql库问题
- Mysql修改密码,远程登录,ERROR 1044 (42000)错误解决办法
- mysql 解决mysql密码忘记问题,修改密码之后登录不成功的问题
- 简化mysql –uroot –p登录 linux忘记mysql密码处理方法 解决root没有权限
- 修改MySQL密码后导致不能再登录phpmyadmin的解决方法
- phpmyadmin登录报错外加linux下修改mysql登录密码
- 登录多实例MySQL失败,修改密码临时解决,原因不明