Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
  • News
  • Artificial Intelligence
  • Applications
  • Linux
No Result
View All Result
Cloudbooklet
No Result
View All Result
Home Linux

How to Install MySQL on Ubuntu 22.04

by Cloudbooklet
1 year ago
in Linux
How To Install Mysql On Ubuntu 22.04
ShareTweetSendShare
ADVERTISEMENT

How to Install MySQL on Ubuntu 22.04. MySQL is the most popular open-source relational database management system which is supported by a huge and active community of open source developers. It is available on over 20 platforms and operating systems including Linux, Unix, Mac and Windows.

In this guide you are going to learn how to install and secure MySQL on Ubuntu 22.04.

This setup is tested on Google Cloud Platform, so it works fine on any cloud services like AWS, Azure or any VPS or Dedicated servers.

ADVERTISEMENT

Install MySQL

Start by updating the packages to the latest version available.

You might also like

Symbolic Links In Linux

Symbolic Links in Linux: What They Are and How to Use Them

2 months ago
Ubuntu Password

Reset your Forgotten Ubuntu Password in 2 Minutes

3 months ago
sudo apt update
sudo apt upgrade

In Ubuntu 22.04 MySQL 8 is included by default in the repositories, so you can install it easily using the apt install command.

sudo apt install mysql-server

Once the installation is completed, the MySQL service will start automatically. To verify that the MySQL server is running, type:

ADVERTISEMENT
sudo service mysql status

The output should show that the service is enabled and running:

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-04-29 00:38:45 UTC; 11s ago
    Process: 13836 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, statu>
   Main PID: 13844 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 1151)
     Memory: 351.4M
        CPU: 1.043s
     CGroup: /system.slice/mysql.service
             └─13844 /usr/sbin/mysqld

Securing MySQL

MySQL installation comes with a script named mysql_secure_installation that allows you to easily improve the MySQL server security.

ADVERTISEMENT
sudo mysql_secure_installation

You will be asked to configure the VALIDATE PASSWORD PLUGIN which is used to test the strength of the MySQL users passwords and improve the security.

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: 

Press y if you want to set up the validate password plugin or any other key to move to the next step.

ADVERTISEMENT

There are three levels of password validation policy, low, medium, and strong.

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: 

Enter 2 for strong password validation.

ADVERTISEMENT

On the next prompt, you will be asked to set a password for the MySQL root user.

Please set the password for root here.

If you set up the validate password plugin, the script will show you the strength of your new password. Type y to confirm the 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) :

Next, you’ll be asked to remove the anonymous user, restrict root user access to the local machine, remove the test database, and reload privilege tables. You should answer y to all questions.

Login to MySQL as root

In MySQL 8.0, the root user is authenticated by the auth_socket plugin by default.

The auth_socket plugin authenticates users that connect from the localhost through the Unix socket file. This means that you can’t authenticate as root by providing a password.

To log in to the MySQL server as the root user, execute the following command.

sudo mysql

You will be presented with the MySQL shell, as shown below:

Now you can change the authentication type which helps you to login to your MySQL server as root using an external program such as phpMyAdmin. Learn how to install PhpMyAdmin for MySQL.

You can do this using two methods listed below.

Method 1: Create New user

This is the recommended option by creating a new dedicated administrative user with access to all databases:

CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES; 

Method 2: Change Authentication Method

You can change the authentication method from auth_socket to mysql_native_password. You can do that by running the following command:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
FLUSH PRIVILEGES;

That’s it. Great!

Prepare yourself for a role working as an Information Technology Professional with Linux operating system

Conclusion

Now you have learned how to install and secure MySQL in Ubuntu 22.04. You have also learned to enable password based authentication.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Tags: MySQLUbuntu 22.04
Share1Tweet1SendShare
Cloudbooklet

Cloudbooklet

Leave a Reply Cancel reply

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

Related Posts

&Quot; Systemd Service On Linux

How to Create a New systemd Service on Linux: A Step-by-Step Guide

3 months ago
List Groups In Linux

How to List Groups in Linux: A Guide for Beginners

3 months ago
Hostname In Linux

How to Modify the Hostname in Linux

3 months ago
Linux Systems

Linux systems Hacked with OpenSSH Malware

3 months ago

Follow Us

Trending Articles

Download Vimeo Videos

7 Best Ways to Download Vimeo Videos

September 23, 2023

Coca Cola Y3000 – AI Generated Coke is Now Available to Taste

AI Powered 3D Models to Create 3D Designs in Breeze

How to Chat with PDF Files Using ChatGPT: A Step-by-Step Guide

Top 10 Ways to Use ChatGPT for Marketing in 2023

5 AI Tools for Business Owners to Make Their Life Easier

Popular Articles

Bulk Email Service

9 Best Bulk Email Service Providers of 2023

September 2, 2023

5 AI Murder Mystery Puzzles and Games to Play Detective Online

5 Free AI Soulmate Maker: Create Your Perfect Match

Amazon Alexa ChatGPT: How It Works and How to Use It

Top 5 Free Linux Cloud Servers to Host Your Website

10 Best Free Naked AI Generator: Make Photos into AI Nudes

Subscribe Now

loader

Subscribe to our mailing list to receives daily updates!

Email Address*

Name

Cloudbooklet Logo

Welcome to our technology blog, where we explore the latest advancements in the field of artificial intelligence (AI) and how they are revolutionizing cloud computing. In this blog, we dive into the powerful capabilities of cloud platforms like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure, and how they are accelerating the adoption and deployment of AI solutions across various industries. Join us on this exciting journey as we explore the endless possibilities of AI and cloud computing.

  • About
  • Contact
  • Disclaimer
  • Privacy Policy

Cloudbooklet © 2023 All rights reserved.

No Result
View All Result
  • News
  • Artificial Intelligence
  • Applications
  • Linux

Cloudbooklet © 2023 All rights reserved.