2

ユーザー「wordpress」を作成し、phpMyAdminを介してmysqlで権限を付与しました。ただし、コマンドラインでユーザーワードプレスとしてログインすると、アクセスできるはずの場所にアクセスできないようです。見てください:

>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か?

さらに、datbase sitedbでワードプレスのすべての(危険な、私は知っていますが、私は健全性テストを行っています)特権を付与しました。sitedbを使用しようとすると(これは同じセッションで)、次のようになります。

mysql> USE sitedb;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'sitedb'

どうしたの?

4

3 に答える 3

0

mysqlユーザーの作成中にエラーが発生したようです。ユーザーを作成し、ターミナルから権限を付与することをお勧めします。

于 2012-12-22T04:51:19.370 に答える
0

MySQLドキュメントから:

USAGE特権指定子は、「特権なし」の略です。</ p>

ユーザーに適切な権限がないようです。正しいデータベースの正しいユーザーに対するすべての権限が付与されていますか?特に、sitedbデータベースのみにすべての権限を付与してみてください。

于 2012-12-22T04:57:32.983 に答える
0

私はそれを考え出した...

私はrootとしてログインし、rootの特権と、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を含める必要があります)?これはある種のセキュリティ機能だと思います...

于 2012-12-22T05:19:45.247 に答える