为什么GRANT在MySQL中不起作用? [英] Why is GRANT not working in MySQL?

查看:214
本文介绍了为什么GRANT在MySQL中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这个问题上scratch之以鼻,因为我看到大量的帮助网站显示了如何创建MySQL用户和授予特权,但是由于某些原因,它对我不起作用.我在WinXP和安装了最新MySQL版本的MacBook Pro笔记本电脑上都尝试过.

I'm scratching my head on this one as I see a ton of helper websites showing how to create MySQL users and grant privileges but for some reason it just does not work for me. I tried on both WinXP and a MacBook Pro laptop with the latest MySQL version installed.

以下仅是我使用WordPress时的一个示例.实际的数据库有些不同,但存在相同的问题.

The following is just an example from when I worked with WordPress. The actual database is something different but same issues.

以下是步骤:

mysql> mysql -uroot -p<password>
mysql> CREATE DATABASE wwordpress;
mysql> CREATE USER 'www'@'localhost' IDENTIFIED BY 'basic';

查询确定,受影响的0行(0.14秒)

Query OK, 0 rows affected (0.14 sec)

mysql> GRANT INSERT ON wordpress.* TO 'www'@'localhost' IDENTIFIED BY 'basic';

查询确定,受影响的0行(0.00秒)

Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;

查询正常,受影响的0行(0.03秒)

Query OK, 0 rows affected (0.03 sec)

mysql> SELECT * FROM mysql.user WHERE User='www' \G


*************************** 1. row ***************************
                 Host: localhost
                 User: www
             Password: *E85C94AF0F09C892339D31CF7570A970BCDC5805
          Select_priv: N
          Insert_priv: N
          Update_priv: N
          Delete_priv: N
          Create_priv: N
            Drop_priv: N
          Reload_priv: N
        Shutdown_priv: N
         Process_priv: N
            File_priv: N
           Grant_priv: N
      References_priv: N
           Index_priv: N
           Alter_priv: N
         Show_db_priv: N
           Super_priv: N
Create_tmp_table_priv: N
     Lock_tables_priv: N
         Execute_priv: N
      Repl_slave_priv: N
     Repl_client_priv: N
     Create_view_priv: N
       Show_view_priv: N
  Create_routine_priv: N
   Alter_routine_priv: N
     Create_user_priv: N
           Event_priv: N
         Trigger_priv: N
             ssl_type:
           ssl_cipher:
          x509_issuer:
         x509_subject:
        max_questions: 0
          max_updates: 0
      max_connections: 0
 max_user_connections: 0
1 row in set (0.00 sec)

mysql>

如您所见,"Insert_priv:N"应为"Y".

As you can see "Insert_priv: N" should be "Y".

有什么建议吗?

谢谢.

推荐答案

您选择的是全局特权. 但是,您要赋予数据库(和主机,但这没关系)特定的特权.

what you are selecting are the global privileges. you are however giving database (and host, but that doesnt matter) specific privileges.

GRANT INSERT ON wordpress .* TO 'www'@'localhost' IDENTIFIED BY 'basic';

这些权限存储在db表中.

只是为了指引您正确的方向

just to point you in the right direction:

SHOW GRANTS FOR 'www'@'localhost'

http://dev.mysql.com/doc/refman/5.0/en/show-grants.html

这篇关于为什么GRANT在MySQL中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆