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  Overcoming The Challenges Of Cleaning Up Container Images

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
  • Engineering

Just make it scale: An Aurora DSQL story

  • May 29, 2025
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

Stay Connected!
LATEST
  • 1
    Just make it scale: An Aurora DSQL story
    • May 29, 2025
  • 2
    Reliance on US tech providers is making IT leaders skittish
    • May 28, 2025
  • Examine the 4 types of edge computing, with examples
    • May 28, 2025
  • AI and private cloud: 2 lessons from Dell Tech World 2025
    • May 28, 2025
  • 5
    TD Synnex named as UK distributor for Cohesity
    • May 28, 2025
  • Weigh these 6 enterprise advantages of storage as a service
    • May 28, 2025
  • 7
    Broadcom’s ‘harsh’ VMware contracts are costing customers up to 1,500% more
    • May 28, 2025
  • 8
    Pulsant targets partner diversity with new IaaS solution
    • May 23, 2025
  • 9
    Growing AI workloads are causing hybrid cloud headaches
    • May 23, 2025
  • Gemma 3n 10
    Announcing Gemma 3n preview: powerful, efficient, mobile-first AI
    • May 22, 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
  • Understand how Windows Server 2025 PAYG licensing works
    • May 20, 2025
  • By the numbers: How upskilling fills the IT skills gap
    • May 21, 2025
  • 3
    Cloud adoption isn’t all it’s cut out to be as enterprises report growing dissatisfaction
    • May 15, 2025
  • 4
    Hybrid cloud is complicated – Red Hat’s new AI assistant wants to solve that
    • May 20, 2025
  • 5
    Google is getting serious on cloud sovereignty
    • May 22, 2025
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.