Advance

How to Install MySQL on Linux Ubuntu 20.04 LTS

How to Install MySQL on Linux Ubuntu 20.04 LTS
0
(0)

In this tutorial, we want to talk at How to Install MySQL on Linux Ubuntu 20.04 LTS in 5 steps and show you how you can install MySQL on Linux Ubuntu 20 Linux server.

Note: You will need root access to install.

Tutorial Install MySQL on Linux Ubuntu 20.04 LTS

Step 1 – Install MySQL Server

After login to your server with root user, update apt, and run install packages with the command below. also, install MySQL server with the command below:

sudo apt update  sudo apt install mysql-server  

After finish the install Mysql, the MySQL service will start automatically. You can check the service status with the command below:

sudo systemctl status mysql  

Step 2 – Secure MySQL Server

Now, here we need to secure the MySQL server. For secure the MySQL you should with root user run command below:

sudo mysql_secure_installation  

Now, Follow the on-screen instructions to finish the wizard.

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  Please set the password for root here.  New password:  Re-enter new password:  Estimated strength of the password: 100  Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y  By default, a MySQL installation has an anonymous user,  allowing anyone to log into MySQL without having to have  a user account created for them. This is intended only for  testing, and to make the installation go a bit smoother.  You should remove them before moving into a production  environment.    Remove anonymous users? (Press y|Y for Yes, any other key for No) : y  Success.  Normally, root should only be allowed to connect from  'localhost'. This ensures that someone cannot guess at  the root password from the network.  Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y  Success.  By default, MySQL comes with a database named 'test' that  anyone can access. This is also intended only for testing,  and should be removed before moving into a production  environment.  Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y  - Dropping test database...  Success.  - Removing privileges on test database...  Success.  Reloading the privilege tables will ensure that all changes  made so far will take effect immediately.  Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y  Success.  All done!  
Recommended Article: How to install MongoDB 4 on Debian 10

Step 3 – Manage MySQL Service

For stop MySQL service, run the command below:

sudo systemctl stop mysql  

For start MySQL service, run the command below:

sudo systemctl start mysql  

For restart MySQL, run the command below:

sudo systemctl restart mysql  

view the status of MySQL service:

sudo systemctl status mysql  

Step 4 – Connect MySQL Server

So far, you’ve installed the MySQL database server on Ubuntu 20.04. Now you should connect to your database server on the command line with the following command.

mysql -u root -p  

Enter the MySQL root user password to connect:

Enter password:  Welcome to the MySQL monitor. Commands end with ; or \g.  Your MySQL connection id is 20  Server version: 8.0.19-0ubuntu5 (Ubuntu)  Copyright (c) 2000, 2020, 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>  

Step 5 – Create MySQL User and Database

Now, Use the following commands to create a database on MySQL.

CREATE DATABASE mydb;  CREATE USER 'myuser'@'localhost' IDENTIFIED by 'Pa$$w0rd';  GRANT ALL on mydb.* to 'myuser'@'localhost'  FLUSH PRIVILEGES  

Congratulations, you have successfully completed the Install MySQL on Linux Ubuntu 20.04 LTS steps.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

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

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day