The main reason for creating another User for MySQL is to have it assigned to a Database and used in an Application. Before it could start making queries to the Database itself it first needs to have privileges to that Database, for this the GRANT command is used. This will work only on an SSD VPS or a Dedicated Server with root access as such is not granted in a Shared Hosting environment
First, we’ll create a User and a Database:
CREATE DATABASE IF NOT EXISTS `example_database` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'user_password';
Now we can add Privileges to that User on the new Database, in our example we’ll grant full privileges:
GRANT ALL PRIVILEGES ON my_database_name.* TO 'newuser'@'localhost' IDENTIFIED BY 'password';
Ready to experiment with different MySQL commands? Try them on our SSD VPS Hosting Plans or get full freedom by managing your own Dedicated Server at a very affordable price!
Useful MySQL Commands: