openstack-db --init --service keystone --pass keystone做了三件事情:
1、mysql> CREATE DATABASE keystone;
2、mysql> GRANT ALL ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'keystone';
3、mysql> GRANT ALL ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone';
我们看看不做第三步会发生什么:
[root@db1 ~]# mysql -u keystone -pkeystone
ERROR 1045 (28000): Access denied for user 'keystone'@'localhost' (using password: YES) 被拒绝登陆了
用空密码尝试登陆:
[root@db1 ~]# mysql -u keystone
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.1.52-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.00 sec) 登陆成功,不过不能显示keystone数据库
那么执行第三步会怎样呢?
mysql> GRANT ALL ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone';
Query OK, 0 rows affected (0.01 sec) 再次模拟登陆:
[root@db1 ~]# mysql -u keystone -pkeystone
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.1.52-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| keystone |
| test |
+--------------------+
3 rows in set (0.01 sec) 登陆成功了