Chinaunix首页 | 论坛 | 博客
  • 博客访问: 371219
  • 博文数量: 114
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1219
  • 用 户 组: 普通用户
  • 注册时间: 2015-02-07 21:23
文章分类

全部博文(114)

文章存档

2018年(1)

2017年(5)

2016年(87)

2015年(21)

我的朋友

分类: 系统运维

2015-10-28 00:07:17


  1. mysqladmin: connect to server at 'localhost' failed
  2.        error: 'Access denied for user 'root'@'localhost' (using password: YES)'
  3. 解决办法:破解mysql密码

  4. #> service mysqld stop
  5.        #>mysqld_safe --skip-grant-tables &
  6.        输入 mysql -uroot -p 回车进入
  7.        >use mysql;
  8.        > update user set password=PASSWORD("newpass")where user="root";
  9.        更改密码为 newpassord
  10.        > flush privileges; 更新权限
  11.        > quit 退出

  12. service mysqld restart
  13.        mysql -uroot -p新密码进入


  14.        二,忘记本地root的登录密码

  15. 解决过程:

  16. 1、编辑/etc/my.cnf

  17. [mysqld] 配置部分添加一行

  18. skip-grant-tables
  19.  

  20. 2、保存后重启mysql

  21. [root@localhost etc]# service mysqld restart
  22. Shutting down MySQL. [ OK ]
  23. Starting MySQL. [ OK ]

  24. 3、登录数据库重新设置root密码


  25. [root@localhost ~]# mysql -uroot -p mysql
  26. Enter password:

  27. 直接回车进入


  28. Welcome to the MySQL monitor. Commands end with ; or \g.
  29. Your MySQL connection id is 1
  30. Server version: 5.1.47-log Source distribution

  31. Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
  32. This software comes with ABSOLUTELY NO WARRANTY. This is free software,
  33. and you are welcome to modify and redistribute it under the GPL v2 license

  34. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  35. mysql> show databases;
  36. +--------------------+
  37. | Database |
  38. +--------------------+
  39. | information_schema |
  40. | mysql |
  41. | test |
  42. +--------------------+
  43. 3 rows in set (0.00 sec)


  44. 执行下列语句

  45. mysql> update user set password=password("mysql") where user='root';
  46. Query OK, 4 rows affected (0.00 sec)
  47. Rows matched: 4 Changed: 4 Warnings: 0

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

  50. 4、删除/etc/my.cnf文件中添加的“skip-grant-tables”行,重启mysql;

  51. 用新设的密码就能正常登录了;

阅读(1125) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~