Install and Setup MySQL on Ubuntu 20.04 LTS

In this article, will show you how to install and setup MySQL on Ubuntu 20.04 LTS Server.

STEP 1 (Install MySQL)

Install MySQL by typing in the terminal :

STEP 2 (Configuring MySQL)

After installed, you need to setup the security for MySQL. By run this command, you will be given a series of prompt to choose security preferences. You can specify your preferences for this setup :

output :

STEP 3 (Create User and Set Previlege)

Login to MySQL as root user using the password that you set before :

after that, type this command to create a new MySQL user. You can create a username as you want, the default host is ‘localhost’, but it’s ok if you only want using username :

Grant previlege to database tables :

or you can grant a user with specific permission by using this command :

to free up server’s memory after create user and grant statements:

in the future, to login as a specific user you can use this command :

STEP 4 (Testing MySQL)

output if running :

to start MySQL :

to stop MySQL :

to restart MySQL :