aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • Engineering
  • Programming
  • Software
  • Software Engineering

How-To: Install MySQL on Ubuntu 22.04

  • aster.cloud
  • September 10, 2022
  • 2 minute read

This guide contains instructions on how to install, secure and uninstall a MySQL database on Ubuntu 22.04. At the time of this writing, the stable version is 8.0

Prerequisites

  • Operating System: Ubuntu 22.04
  • Access to a terminal or console

Installation via Package Manager

01. Open a terminal window


Partner with aster.cloud
for your next big idea.
Let us know here.



From our partners:

CITI.IO :: Business. Institutions. Society. Global Political Economy.
CYBERPOGO.COM :: For the Arts, Sciences, and Technology.
DADAHACKS.COM :: Parenting For The Rest Of Us.
ZEDISTA.COM :: Entertainment. Sports. Culture. Escape.
TAKUMAKU.COM :: For The Hearth And Home.
ASTER.CLOUD :: From The Cloud And Beyond.
LIWAIWAI.COM :: Intelligence, Inside and Outside.
GLOBALCLOUDPLATFORMS.COM :: For The World's Computing Needs.
FIREGULAMAN.COM :: For The Fire In The Belly Of The Coder.
ASTERCASTER.COM :: Supra Astra. Beyond The Stars.
BARTDAY.COM :: Prosperity For Everyone.

02. Update the package repository and install MySQL. This will install the latest and most stable version of the database.

$ sudo apt update$ sudo apt install mysql-server -y

03. Verify the MySQL has been installed

$ mysql --version

Set a new root password

Securing the MySQL database is a recommended step.

01. Access the MySQL shell.

$ sudo mysql

02. Set a new password for MySQL

$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123g33kN1kolaT3sl@';

 

Exit

mysql> exit

Securing the MySQL

01. Run MySQL secure installation. Enter the root password specified in the previous steps.

$ sudo /usr/bin/mysql_secure_installation

02. Enter y to validate the password for other accounts that will be created.

03. Enter 2 option for a STRONG password

04. Optional. Replacing the root password. Choose a strong password with the following criteria. In this example we are not changing the password.

  • Minimum length : 8
  • Has a number [0-9]
  • Has a lower case character [a-z]
  • Has an upper case character [A-Z]
  • Has a special character (e.g. @, $, %, etc.)

05. Choose no or any other character beside y/Y.

06. Remove the anonymous user by entering y. It is advisable to remove the anonymous user.

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.

07. Disallow root login remotely. This is a security concern, if you don’t want the root user to be accessible remotely. Enter y.

Read More  Redacting PII Data In Dialogflow CX With Google Cloud Data Loss Prevention (DLP)

If root access is really required, we recommend disallowing root login remotely and use an SSH tunnel instead to connect.

08. Remove the test database, enter y.

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.

09. Enter y to reload the privilege tables.

10. Setup to secure is now complete.

11. Test the MySQL config, by login using the root account.

$ sudo mysql -u root -p
# Enter the root password

Uninstalling MySQL Server

Change to the root user. To avoid typing sudo multiple times.

$ sudo su -

Uninstall the mysql-server package. Review the packages to be removed and accept it with y.

$ apt-get remove mysql-server

Run autoremove to remove packages that are not needed anymore. Packages that have no more dependencies.

$ apt-get autoremove

Remove the installation directory for MySQL.

# rm -rf /var/lib/mysql

Verify that MySQL has been uninstalled by checking the MySQL version.

# mysql

 


For enquiries, product placements, sponsorships, and collaborations, connect with us at [email protected]. We'd love to hear from you!

Our humans need coffee too! Your support is highly appreciated, thank you!

aster.cloud

You May Also Like
View Post
  • Software
  • Technology

Canonical Releases Ubuntu 25.04 Plucky Puffin

  • April 17, 2025
View Post
  • Software
  • Technology

IBM Accelerates Momentum in the as a Service Space with Growing Portfolio of Tools Simplifying Infrastructure Management

  • March 27, 2025
View Post
  • Engineering
  • Technology

Guide: Our top four AI Hypercomputer use cases, reference architectures and tutorials

  • March 9, 2025
View Post
  • Software Engineering
  • Technology

Claude 3.7 Sonnet and Claude Code

  • February 25, 2025
View Post
  • Computing
  • Engineering

Why a decades old architecture decision is impeding the power of AI computing

  • February 19, 2025
View Post
  • Engineering
  • Software Engineering

This Month in Julia World

  • January 17, 2025
View Post
  • Engineering
  • Software Engineering

Google Summer of Code 2025 is here!

  • January 17, 2025
View Post
  • Data
  • Engineering

Hiding in Plain Site: Attackers Sneaking Malware into Images on Websites

  • January 16, 2025

Stay Connected!
LATEST
  • college-of-cardinals-2025 1
    The Definitive Who’s Who of the 2025 Papal Conclave
    • May 7, 2025
  • conclave-poster-black-smoke 2
    The World Is Revalidating Itself
    • May 6, 2025
  • oracle-ibm 3
    IBM and Oracle Expand Partnership to Advance Agentic AI and Hybrid Cloud
    • May 6, 2025
  • 4
    Conclave: How A New Pope Is Chosen
    • April 25, 2025
  • Getting things done makes her feel amazing 5
    Nurturing Minds in the Digital Revolution
    • April 25, 2025
  • 6
    AI is automating our jobs – but values need to change if we are to be liberated by it
    • April 17, 2025
  • 7
    Canonical Releases Ubuntu 25.04 Plucky Puffin
    • April 17, 2025
  • 8
    United States Army Enterprise Cloud Management Agency Expands its Oracle Defense Cloud Services
    • April 15, 2025
  • 9
    Tokyo Electron and IBM Renew Collaboration for Advanced Semiconductor Technology
    • April 2, 2025
  • 10
    IBM Accelerates Momentum in the as a Service Space with Growing Portfolio of Tools Simplifying Infrastructure Management
    • March 27, 2025
about
Hello World!

We are aster.cloud. We’re created by programmers for programmers.

Our site aims to provide guides, programming tips, reviews, and interesting materials for tech people and those who want to learn in general.

We would like to hear from you.

If you have any feedback, enquiries, or sponsorship request, kindly reach out to us at:

[email protected]
Most Popular
  • 1
    Tariffs, Trump, and Other Things That Start With T – They’re Not The Problem, It’s How We Use Them
    • March 25, 2025
  • 2
    IBM contributes key open-source projects to Linux Foundation to advance AI community participation
    • March 22, 2025
  • 3
    Co-op mode: New partners driving the future of gaming with AI
    • March 22, 2025
  • 4
    Mitsubishi Motors Canada Launches AI-Powered “Intelligent Companion” to Transform the 2025 Outlander Buying Experience
    • March 10, 2025
  • PiPiPi 5
    The Unexpected Pi-Fect Deals This March 14
    • March 13, 2025
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.