I had to setup a few test databases recently and I had forgotten how to create a new local user. For future reference.
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
You can also use the percent sign to allow both local and remote access.
CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';
In order to allow permissions to tables you need to grant privileges. This command will grant your user privileges to all databases on the server. Not normally what you would do as it is not very secure but in this case I am just setting up a test on a VM inside the local network.
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
When you are all done you will need to reload the permissions in order for them to take effect.
FLUSH PRIVILEGES;
References:
http://dev.mysql.com/doc/refman/5.7/en/create-user.html
https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql
No comments:
Post a Comment