你好,游客 登录 注册 搜索
背景:
阅读新闻

CentOS Linux下用yum 安装MySQL

[日期:2013-05-04] 来源:Linux社区  作者:wangrouyi [字体:大 中 小]

[2] 测试设置的root密码是否生效

 

[root@192 local]# mysql -u root ← 通过空密码用root登录
ERROR 1045 (28000): Access denied for user
'root'@'localhost' (using password: NO)
← 出现此错误信息说明密码设置成功

[root@192 local]# mysql -u root-p ← 通过密码用root登录
Enter password: ← 在这里输入密码


Welcome to the MySQL monitor. Commands end with ; or \g. ← 确认用密码能够成功登录
Your MySQL connection id is 5
Server version: 5.0.95 Source distribution

... ...

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

[root@192 local]#mysql -u root -h 127.0.0.1 -p ← 通过密码用root登录
Enter password: ← 在这里输入密码
Welcome to the MySQL monitor. Commands end with ; or \g.← 确认用密码能够成功登录
Your MySQL connection id is 13
Server version: 5.0.95 Source distribution

......

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

mysql> exit  ← 退出MySQL服务器
Bye

 

[3] 删除匿名用户

 

在MySQL刚刚被安装后,存在用户名、密码为空的用户。这使得数据库服务器有无需密码被登录的可能性。为消除隐患,将匿名用户删除。

 

[root@192 local]# mysql -u root -p; ← 通过密码用root登录
Enter password: ← 在这里输入密码

 

mysql> select user,host from mysql.user;
+------+-------------+
| user | host |
+------+-------------+
| root | 127.0.0.1 |
| | 192.168.0.1 |
| root | 192.168.0.1 |
| | localhost |
| root | localhost |
+------+-------------+
5 rows in set (0.03 sec)

 

mysql> delete from mysql.user where user=''; ← 删除匿名用户

Query OK, 2 rows affected (0.04 sec)

 

mysql> select user,host from mysql.user; ← 查看用户信息

+------+-------------+
| user | host |
+------+-------------+
| root | 127.0.0.1 |
| root | 192.168.0.1 |
| root | localhost |
+------+-------------+
3 rows in set (0.00 sec)

 

mysql>flush privileges; ← 刷新,使以上操作生效

mysql> exit; ←退出MySQL服务器
Bye

linux
相关资讯       CentOS yum MySQL 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款