Reputation: 516
This should be a really simple process but for whatever reason, I am unable to add a column to an MySQL table. Here's my syntax:
$query = "ALTER TABLE game_licenses ADD lifetime VARCHAR(255) AFTER expire_date";
$result = mysql_query($query);
if (!$result) {
echo "it failed";
}
else {
echo "success";
}
I've tried multiple little changes like adding COLUMN to the query after ADD. There are no MySQL errors but finishes the script and echos "it failed".
The error is:
ALTER command denied to user 'webuser'@'localhost'
Is it possible to lock a table from being altered?
Upvotes: 7
Views: 15223
Reputation: 76753
You don't have the privileges to do so.
Make sure you have the alter
privilege on that table.
Have the superuser (root) execute the following:
GRANT ALTER ON dbname.game_licences TO `webuser`@`localhost`
See: http://dev.mysql.com/doc/refman/5.1/en/grant.html.
P.S. Are you sure you want normal users to be able to issue alter
statements?
Better option may be to issue the alter statement as root, or even better to make an admin account that has full rights on the database, but not full rights on any other database.
Upvotes: 9