Install and Setup MySQL on Ubuntu 20.04 LTS

$ sudo apt update
$ sudo apt install mysql-server
$ sudo mysql_secure_installation
Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: Y

There are three levels of password validation policy:

LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
2
$ sudo mysql -u root -p
mysql> CREATE USER 'username'@'host' IDENTIFIED BY 'password';
mysql> GRANT PREVILEGE ON database.table TO 'username'@'host';
mysql> GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO user'@'localhost' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
$ sudo mysql -u daniel -p
$ sudo systemctl status mysql.service
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2020-04-21 12:56:48 UTC; 6min ago
Main PID: 10382 (mysqld)
Status: "Server is operational"
Tasks: 39 (limit: 1137)
Memory: 370.0M
CGroup: /system.slice/mysql.service
└─10382 /usr/sbin/mysqld
$ sudo systemctl start mysql
$ sudo systemctl stop mysql
$ sudo systemctl restart mysql

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Persistent Data Structures — Part I: The Persistent List

Superhero Wallet Gets an Update!

5 Reason to choose MEAN Stack Development

Setup and installation for windows

Guide for an ultimate Tech Career

Some Discord Could Be Good For Healthcare

How To Architect e-commerce solution for the Cloud using AWS or Microsoft Azure

Basic of Git

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Daniel Santoso

Daniel Santoso

More from Medium

Hosting multiple containerized websites on a single server

Docker Alternatives for windows and mac?

How to Manage and Use Apache virtual hosts in Ubuntu

How To Setup Nginx Reverse Proxy Server On Ubuntu 20.04