Wednesday, March 16, 2011

Creating a new MySQL database with user

I do the following:
  1. Start -> Programs -> MySQL -> MySQL Server 5.1 -> MySQL Command Line Client and provide password.
  2. At mysql> prompt, type show databases;. This will display the existing databases.
  3. To create a database "love", I'll run create database love;.
  4.  Now if you try show databases, you'll see the "love" database.
But I want to be more fancy. I want the database love to be accessible by "lovely" with password "deadly" only from local machine. To do that execute the following query:

mysql> CREATE USER 'lovely'@'localhost' IDENTIFIED BY 'deadly';
Query OK, 0 rows affected (0.00 sec)


mysql> grant all privileges on love.* to 'lovely'@'localhost' with grant option;
Query OK, 0 rows affected (0.00 sec) 
 

1 comment:

  1. Woori Casino: 150 FS Free Spins | Sign up and Get 500
    Woori Casino - 500 FS Free 188bet Spins, no Deposit required at all. Min deposit €10 and bonus code WYTECASINO. Claim 12bet free spins, sign up and 우리카지노 play now!

    ReplyDelete