Labels

Wednesday, January 23, 2013

How-To create a MySQL database and set privileges to a user

########## Creating A Database & Database user [tweecart]
Login : server

On a default settings, mysql root user do not need a password to authenticate from localhost.
In this case, ou can login as root on your mysql server using:
   
    $ mysql -u root
   
If a password is required, use the extra switch -p:
   
    $ mysql -u root -p
    Enter password:
   
Now that you are logged in, we create a database:

    mysql> create database tweecart_db;
    Query OK, 1 row affected (0.00 sec)
   
We allow user tweecart to connect to the server from localhost using the password tweecartpasswd:

    mysql> grant usage on *.* to tweecart@localhost identified by 'tweecartpasswd';
    Query OK, 0 rows affected (0.00 sec)
   
And finally we grant all privileges on the tweecart database to this user:
    mysql> grant all privileges on tweecart_db.* to tweecart@localhost;
    Query OK, 0 rows affected (0.00 sec)
   
Check : goto : http://domainname.com/phpmyadmin
User      : tweecart
Password : tweecartpasswd

===================================
In short : 
Login your Server : 

$ mysql -u root -p
    Enter password:

mysql> create database tweecart_db;
mysql> grant usage on *.* to tweecart@localhost identified by 'tweecartpasswd';
mysql> grant all privileges on tweecart_db.* to tweecart@localhost;

Check : goto : http://domainname.com/phpmyadmin
User      : tweecart
Password : tweecartpasswd