免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1512 | 回复: 0
打印 上一主题 下一主题

解决mysql“Access denied for user \'root\'@\'localhost\'” [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-21 08:42 |只看该作者 |倒序浏览
解决mysql“Access denied for user 'root'@'localhost'
 
 
大致意思就是给mysql中的root用户添加密码 (密码我就用******表示)

[ooo@localhost ~]$ mysqladmin -u root -p ******
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'

[ooo@localhost ~]$ sudo /etc/init.d/mysqld stop
停止 MySQL: [确定]


[ooo@localhost ~]$ sudo mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 17641

[ooo@localhost ~]$ nohup: ignoring input and redirecting stderr to stdout
Starting mysqld daemon with databases from /var/lib/mysql
mysql -u root mysql (注意这里要自己输入 没提示的)
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.67 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> UPDATE user SET Password=PASSWORD('******') where USER='root';
Query OK, 3 rows affected (0.02 sec)
Rows matched: 3 Changed: 3 Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye


[ooo@localhost ~]$ sudo /etc/init.d/mysqld restart
STOPPING server from pid file /var/run/mysqld/mysqld.pid
081205 12:11:33 mysqld ended

停止 MySQL: [确定]
启动 MySQL: [确定]
[1]+ Done sudo mysqld_safe --user=mysql --skip-grant-tables --skip-networking
[ooo@localhost ~]$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.67 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)

mysql> quit
Bye
[ooo@localhost ~]$
上述是转帖,新装的SUSE10自带的Mysql默认是没有密码的,同样可以利用上述方法修改密码。
 
 
 
 
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP