• Time to read less than 1 minute

Here is how to create an SQL database and grant the adequate permissions for a defined server user. In this example, we're creating a database instance with the following parameters:

  • User name: dbAdmin
  • Database name: myDatabase
  • Server host: localhost

Using your favourite command line tool, connect to the SQL server and run the following command:


This will create the database instance. Then run the following command to allow the named user to connect to the newly created database. For simplicity, we assume that all privileges are required for the user in question:

GRANT ALL PRIVILEGES ON myDatabase.* to 'dbAdmin'@'localhost';

Finally, flush the privileges in order to apply the newly defined permissions:


You now have a database named myDatabase that can be accessed by the user dbAdmin, which has all permissions to perform actions on the instance.