MySQL won't let me add a column

This should be a really simple process, but for some reason I cannot add a column to the MySQL table. Here is 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 tried a few small changes, such as adding COLUMN to the query after ADD. There are no MySQL errors, but the script ends and echos "it failed".

Error:

ALTER command denied to user 'webuser' @ 'localhost'

Is it possible to block a table from changing?

+6
source share
1 answer

You do not have privileges for this.

Make sure you have alter privilege in this table.

Ask the superuser (root) to do the following:

 GRANT ALTER ON dbname.game_licences TO `webuser`@`localhost` 

See: http://dev.mysql.com/doc/refman/5.1/en/grant.html .

PS Are you sure you want normal users to be able to issue alter instructions?

The best option would be to issue the alter instruction as root, or even make an administrator account that has full rights to the database, but not full rights to any other database.

+6
source

Source: https://habr.com/ru/post/901220/


All Articles