MySQL database creation
Setting up a database and creating a user to have access to it is quite a simple job.
First, you need to log on as a privileged user to the mysql database, for example the root user.
SQL> create database my_db;
SQL> grant all privileges on my_db.* to my_user@localhost identified by ‘my_password’;
SQL> grant all privileges on my_db.* to my_user;
SQL> flush privileges;
The "all privileges" directive specifies the user can do everything except grant privileges to other users and control mysql (i.e. shut it down etc).
the username requires the "@localhost" as the host is actually part of the username. This is also a preferred security measure (without running the second grant option). If you omit the hostname in the username the user will be able to log in from any host with the exception of localhost.
For more information on specific grants and what they all mean, see the MySQL GRANT reference page.


