As stated in the comment that I made this is giving permission to a user, which is not yet created, you must first create the user:
CREATE USER 'usuario'@'localhost' IDENTIFIED BY 'clave';
Try this to give you access to the dbTest database:
GRANT ALL PRIVILEGES ON dbPrueba.* To 'usuario'@'localhost';
Then, to reload the newly assigned permissions, execute:
FLUSH PRIVILEGES;
Example in a line:
CREATE USER 'usuario'@'localhost' IDENTIFIED BY 'clave'; GRANT ALL PRIVILEGES ON baseDatos.* To 'usuario'@'localhost' IDENTIFIED BY 'clave'; FLUSH PRIVILEGES;
Usage:
-
GRANT
: This is the command used to create users and grant rights to databases, tables, etc.
-
ALL PRIVILEGES
: This tells you that the user will have all the standard privileges. However, this does not include the privilege of using the GRANT
command.
-
dbPrueba.*
This MySQL instruction to apply these rights for use in the entire dbTest database. You can replace *
with specific table names or save routines if you wish.
-
TO 'usuario'@'localhost'
: Is the username of the user account you are creating. Note: you must have the single quotes there. 'localhost' tells MySQL what hosts
the user can connect to. If you only want it from the same machine, use localhost
-
IDENTIFIED BY 'clave'
: As you may have guessed, this sets the password for that user.
Update:
Check the permissions that the previous command issued for that user by executing the following command.
SHOW GRANTS FOR 'usuario'@'localhost'
In the comments, it tells me that although it is believed that it is not allowed to be accessed, try to create the user once logged as root
$ mysql -u root -p -e "grant all privileges on baseDatos.* to
'{usuario}'@'{localhost}' identified by '{clave}'; flush privileges;"
Ignore the -p option, if the mysql
user does not have a password or simply press the Enter button to skip.