DevPush

How to install MySQL on Ubuntu 24.04

Terminal app

To be able to install MySQL you need to use the Terminal.

To open click the Show Apps icon in the dock, then open the terminal app.

How to install MySQL

Run the following commands to install MySQL.

Run the apt update command to update the application repositories used to install applications.

sudo apt update

Next, run the command to install MySQL.

sudo apt install mysql-server

You can use the following command to verify that the MySQL service is running on your system.

sudo service mysql status

To exit the status hold down the Ctrl button and then press the C button.

Change root password

If you want to use a MySQL client application such as HeidiSQL you need to set a password for the default MySQL root user account.

Go back to the terminal and run the following commands.

Login to MySQL using the sudo command.

sudo mysql

While logged in use the following to set the password, the text ‘pass’ is where you set the actual password that you want for the root user.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'pass';

Log out of MySQL.

exit

Restart the MySQL service to apply the change.

sudo service mysql restart

Login as root in your MySQL Client

Open up your MySQL client application and use the following details to log in.

  • Host: localhost
  • Port: 3306
  • User: root
  • Password: The password you set

You should now be able to work with MySQL inside of the application to create databases, tables, and data.