Creating mysql database, user and granting the permissions in ubuntu

If you have not installed mysql server, use below command, or if you have it installed, skip it.

sudo apt-get install mysql-server

Now, login to mysql shell using below command,

$ mysql -u root -p

Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 53
Server version: 5.5.47-0ubuntu0.14.04.1 (Ubuntu)

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

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

Create a New Database

mysql> CREATE DATABASE mydatabase_name;

Query OK, 1 row affected (0.02 sec)

Create a New User

mysql> CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';

Query OK, 0 rows affected (0.06 sec)

Grant permissions for this new user to all databases

mysql> GRANT ALL PRIVILEGES ON * . * TO 'myuser'@'localhost';

Query OK, 0 rows affected (0.00 sec)

The asterisks in this command refer to the database and table (respectively) that they can access—this specific command allows to the user to read, edit, execute and perform all tasks across all the databases and tables.

Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Content Management System - CMS Core Kernel C Programs Development Environment Setup Errors & Failures File Systems git Go Language Programs Hardware Platforms Home HTML JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply