Collections:
Fixing INSERT Command Denied Error in MySQL
How To Fix the INSERT Command Denied Error in MySQL?
✍: FYIcenter.com
The reason for getting the "1142: INSERT command denied" error is that your user account does not have the INSERT privilege on the table or database. To resolve this error, you need to ask your MySQL DBA to grant you the right privilege.
Your DBA will need to run commands like these to grant you enough privileges :
GRANT INSERT ON fyi.* TO dev; GRANT UPDATE ON fyi.* TO dev; GRANT DELETE ON fyi.* TO dev; GRANT SELECT ON fyi.* TO dev; GRANT CREATE ON fyi.* TO dev; GRANT DROP ON fyi.* TO dev;
Once you got the right privileges, run the following tutorial scrip again:
<?php
include "mysql_connection.php";
$sql = "INSERT INTO fyi_links (id, url) VALUES ("
. " 101, 'dev.fyicenter.com')";
if (mysql_query($sql, $con)) {
print(mysql_affected_rows() . " rows inserted.\n");
} else {
print("SQL statement failed with error:\n");
print(mysql_errno($con).": ".mysql_error($con)."\n");
}
$sql = "INSERT INTO fyi_links (id, url) VALUES ("
. " 102, 'dba.fyicenter.com')";
if (mysql_query($sql, $con)) {
print(mysql_affected_rows() . " rows inserted.\n");
} else {
print("SQL statement failed with error:\n");
print(mysql_errno($con).": ".mysql_error($con)."\n");
}
mysql_close($con);
?>
The script should return this:
1 rows inserted. 1 rows inserted.
⇒ Inserting Rows with a SELECT Statement in MySQL
⇐ Inserting Data into an Existing Table in MySQL
2017-10-08, 6165🔥, 0💬
Popular Posts:
How To Update Multiple Rows with One UPDATE Statement in SQL Server? If the WHERE clause in an UPDAT...
How To Calculate Age in Days, Hours and Minutes in SQL Server Transact-SQL? On many Web sites, news ...
How To Install Oracle Database 10g XE in Oracle? To install 10g universal edition, double click, Ora...
What Is SQL*Plus in Oracle? SQL*Plus is an interactive and batch query tool that is installed with e...
Where to find MySQL database server tutorials? Here is a collection of tutorials, tips and FAQs for ...