我创建了用户'wordpress'并通过phpMyAdmin在mysql中授予了权限。但是,当我作为用户wordpress登录命令行时,我似乎无法访问我应该能够访问的内容。看看:
>mysql -u wordpress
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.27 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SHOW GRANTS;
+--------------------------------------+
| Grants for @localhost |
+--------------------------------------+
| GRANT USAGE ON *.* TO ''@'localhost' |
+--------------------------------------+
1 row in set (0.00 sec)
这不应该显示Grants for wordpress@localhost
吗?
此外,我在数据库sitedb上授予所有(危险,我知道,但我是健全性测试)wordpress的权利。当我尝试使用sitedb(在同一个会话中)时,我得到以下内容:
mysql> USE sitedb;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'sitedb'
怎么了?
答案 0 :(得分:0)
看起来创建mysql用户时出现了一些错误,我建议你从终端创建用户和授予权限。
答案 1 :(得分:0)
答案 2 :(得分:0)
我明白了......
我以root身份登录并检查了root的priveleges以及它与wordpress的不同之处:
mysql> SHOW GRANTS;
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> SHOW GRANTS FOR wordpress;
+-----------------------------------------------------------------------------+
| Grants for wordpress@% |
+-----------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'%' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `skytreader`.* TO 'wordpress'@'%' WITH GRANT OPTION |
+-----------------------------------------------------------------------------+
2 rows in set (0.00 sec)
目前,我能收集的唯一区别是主持人。我回到phpMyAdmin更改用户wordpress的主机并将其指定为'localhost'。而且,
>mysql -u wordpress
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.5.27 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SHOW GRANTS;
+-------------------------------------------------------------------------------------+
| Grants for wordpress@localhost |
+-------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `skytreader`.* TO 'wordpress'@'localhost' WITH GRANT OPTION |
+-------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> USE sitedb;
Database changed
现在我想知道为什么会这样?是不是'wordpress'@'%'应该代表外卡主机(所以它应该包括localhost)?我猜这是某种安全功能......