Create MySQl Database and User

MySQL

1. Login to MySQL with root credentials

$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.5.49-0ubuntu0.14.04.1 (Ubuntu)

Copyright (c) 2000, 2016, 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.

2. Create database mydb

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

3. Create user my_user

mysql> create user 'my_user'@"localhost" identified by "qwP3$5";
Query OK, 0 rows affected (0.00 sec)

4. Give all privileges to user my_user

mysql> grant all privileges on mydb.* to 'my_user' with grant option;
Query OK, 0 rows affected (0.04 sec)

5. And then exit

mysql> exit
Bye

arstech

Leave a Reply

Your email address will not be published. Required fields are marked *