Creating new user and new MySQL Database

If you want to create a new user example with a database that they have control over, we will run the following commands.
Note: That ‘mysql>’ is the command prompt for the client program MySQL.

Connect to the local database server as user root. You will be prompted for a password.

# mysql -h localhost -u root -p

Now we see the ‘mysql>’ prompt and we can run the following to create a new database for Example.

mysql> create database exampledb;
Query OK, 1 row affected (0.00 sec)

Now we create the user Example and give him/her permissions on the new database

mysql> grant DROP,CREATE,INSERT,DELETE,UPDATE,SELECT on exampledb.* to example@localhost;
Query OK, 0 rows affected (0.00 sec)

Next we set a password for this new user

mysql> set password for example = password(‘mysecretpassword’);
Query OK, 0 rows affected (0.00 sec)

Cleanup

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

Exit

mysql> exit;

Once all this has done you have created a new user with complete control over the contents of the database exampledb – the user can create new tables, delete/drop them and generally use the database.
Note: The new user will have no other access to the server, only to the database that you gave them permissions to.

Reference:
Debian Administration

Comments (1)

  1. 7:37, Sunday, June 29, 2008transunion  / Reply

    Nice Site!
    http://google.com

Leave a Reply

Pingbacks (0)

› No pingbacks yet.

%d bloggers like this: