插入命令在MySQL中被拒绝 [英] insert command denied in mysql

查看:166
本文介绍了插入命令在MySQL中被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库表,当我选择具有用户名和密码的数据时,它可以工作,但是当我在具有相同用户名和密码的表中插入一些数据时,它会向我显示错误

I have a database table from which, when I select data with username and password, it works but when I insert some data in that table with same username and password it shows me the error

INSERT command denied to user 'username'@'localhost' for table 'tablename'

我使用Google进行搜索,其他人在数据库大小方面也遇到了同样的问题.我检查了数据库,当我直接进入phpmyadmin将数据插入表中时,它可以工作,但是当我从PHP脚本调用对该表的查询时,它给了我错误.

I searched using Google and someone else had the same problem with db size. I checked my db and when I go directly to phpmyadmin to insert data into the table, it works, but when I call a query to the table from a PHP script, it gives me the error.

推荐答案

这是权限问题.使用运行该应用程序的用户登录到MySQL提示符,然后输入以下查询:

This is a permissions problem. Log into a MySQL prompt with the user the app is running as, and enter this query:

SHOW GRANTS;

这将向您显示特权(授予用MySQL讲)当前用户拥有的.我的猜测是,您将看不到给定表的INSERT特权.您将需要root用户通过运行以下查询来授予您权限:

This will show you the privileges (grants in MySQL-speak) that the current user has. My guess is that you won't see INSERT privileges for the given table. You will need the root user to grant you permission by running this query:

GRANT INSERT ON 'db'.'tablename' TO 'username'@'localhost'

这篇关于插入命令在MySQL中被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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