Quantcast
Channel: BryMayor.com
Viewing all articles
Browse latest Browse all 10

How To Create a MySQL Database and Set Privileges to a User

$
0
0

In this tutorial, I will explain how to create a database as well as the user. Given that your have an access to the database, we are going to create a database called jungle which will be accessible from localhost to user monkey identified by the password mojojojo.

Enter the mysql command line:

$ mysql -uroot -p

where root is your mysql username.

Now that you are logged in, we create the database:

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

We allow user monkey to connect to the server from localhost using the password mojojojo:

mysql> grant usage on *.* to monkey@localhost identified by 'mojojojo';
Query OK, 0 rows affected (0.00 sec)

And finally we grant all privileges on the jungle database to this user:

mysql> grant all privileges on jungle.* to monkey@localhost ;
Query OK, 0 rows affected (0.00 sec)

Done! To check if you can connect to the MySQL server:

$ mysql -umonkey -pmojojojo jungle

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 598
Server version: 5.5.29-0ubuntu0.12.04.1 (Ubuntu)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

 

Always think twice before hitting the Enter key…

 

 

The post How To Create a MySQL Database and Set Privileges to a User appeared first on BryMayor.com.


Viewing all articles
Browse latest Browse all 10

Trending Articles