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

单台[DELL R720]服务器部署多个MySQL实例

[日期:2014-10-19] 来源:Linux社区  作者:tom_resin [字体:大 中 小]

二、配置MySQL数据库

2.1 访问测试登陆情况

mysql -uroot -p-S /data/3306/mysql.sock

Enter password:

Welcome to theMySQL monitor. Commands end with ; or \g.

Your MySQLconnection id is 1

Server version:5.1.51-log Source distribution

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

mysql>select version();

+------------+

| version() |

+------------+

| 5.1.51-log |

+------------+

1 row in set(0.02 sec)

mysql>system mysql -uroot -p -S /data/3307/mysql.sock #-->system的用法

Enter password:

Welcome to theMySQL monitor. Commands end with ; or \g.

Your MySQLconnection id is 1

Server version:5.1.51-log Source distribution

Copyright (c)2000, 2010, Oracle and/or its affiliates. All rights reserved.

This softwarecomes with ABSOLUTELY NO WARRANTY. This is free software,

and you arewelcome to modify and redistribute it under the GPL v2 license

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

mysql> showdatabases;

+--------------------+

| Database |

+--------------------+

|information_schema |

| mysql |

| test |

+--------------------+

3 rows in set(0.01 sec)

mysql> quit

Bye

提示:安装完mysql初始登陆管理员root用户无密码。

更改root密码

mysqladmin -uroot password 'bdkyr14511' -S/data/3306/mysql.sock

mysqladmin -uroot password 'bdkyr14511' -S/data/3307/mysql.sock

#测试改密码后的登陆情况

mysql -uroot -p'bdkyr14511' -S /data/3306/mysql.sock

Welcome to theMySQL monitor. Commands end with ; or \g.

Your MySQLconnection id is 3

Server version:5.1.51-log Source distribution

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

mysql> system mysql -uroot -p'bdkyr14511' -S /data/3307/mysql.sock

ERROR 1045(28000): Access denied for user 'root'@'localhost' (using password: YES)

mysql>system mysql -uroot -p'bdkyr14511' -S /data/3307/mysql.sock

Welcome to theMySQL monitor. Commands end with ; or \g.

Your MySQLconnection id is 4

Server version:5.1.51-log Source distribution

Copyright (c)2000, 2010, Oracle and/or its affiliates. All rights reserved.

This softwarecomes with ABSOLUTELY NO WARRANTY. This is free software,

and you arewelcome to modify and redistribute it under the GPL v2 license

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

提示:一般产品环境,禁止将密码写在命令行中,非常危险。

2.2清理系统默认的多余mysql用户

mysql -uroot -p'bdkyr14511' -S /data/3306/mysql.sock

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQLconnection id is 4

Server version:5.1.51-log Source distribution

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

mysql>select user,host from mysql.user;

+------+-----------+

| user | host |

+------+-----------+

| root |127.0.0.1 |

| | A |

| root | A |

| | localhost |

| root |localhost |

+------+-----------+

5 rows in set(0.00 sec)

mysql> dropuser ''@'localhost';

Query OK, 0rows affected (0.04 sec)

mysql> dropuser ''@'A';

Query OK, 0rows affected (0.01 sec)

mysql> dropuser 'root'@'A';

Query OK, 0rows affected (0.00 sec)

mysql>select user,host from mysql.user;

+------+-----------+

| user | host |

+------+-----------+

| root |127.0.0.1 |

| root |localhost |

+------+-----------+

2 rows in set(0.00 sec)

用同样的方法处理3307的用户。

处理后结果:

mysql>select user,host from mysql.user;

+------+-----------+

| user | host |

+------+-----------+

| root |127.0.0.1 |

| root |localhost |

+------+-----------+

2 rows in set(0.00 sec)

本文永久更新链接地址:http://www.linuxidc.com/Linux/2014-10/108223.htm

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

       

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