Install MySQL on Ubuntu

I’ll cover how to install MySQL Server on Ubuntu 18.04 Server. MySQL is a popular and widely used relational databases amongst developers, especially Linux based development projects.

Many developers prefer to use Ubuntu servers for their deployment servers, although a statement like that is obviously going to be met with some backlash from the Linux community and like any community people will have a difference of opinion. Personally, Ubuntu is my distribution of choice.

Installing mySql on Ubuntu servers is a relatively simple task, becasue mySql is available in the Ubuntu apt repository, which means it can be installed via the terminal as follows.

Advice

In this post we assume you are not logged in as root, and therefore require to elevate your privelege to the root user. If you are logged in as root, simply omit sudo from the commands

Shell

We can now install mysql

Shell

Depending on the installation process and package version you may be prompted to provide some additional information. I have noticed this has varied over the past few months so it is difficult to document definitively.

Once the installation is complete simply check the status of the service.

Shell

The mysql services for Ubuntu should be configured to start automatically. If not you can do this as follows.

Shell

Login into mySql Console

MySQL root user on Ubuntu does not have password and its use auth_socket plugin to authenticate the root user. You can only login to the MySQL root using the system root account or using the sudo command:

Shell

If you would like to set mysql root password, run the ALTER USERcommand as follows:

Shell

Summary

The above presented easy to follow guide to installing mySQL on Ubuntu. We did not cover the more complex security and administration process which you should bear in mind once you have installed the server.

Gary Woodfine

Technical Director at Denizon
Gary is Technical Director at Denizon, an independent software vendor specialising in IoT, Field Service and associated managed services,enabling customers to be efficient, productive, secure and scalable in a way which helps them address and reduce their ecological impact.

Denizon's product line successfully integrate IoT, Artificial Intelligence and Blockchain technology to enable efficient, productive, secure and scalable solutions to help organisations address increasing energy demands, ecological impact and Health & Safety concerns of their staff.

Latest posts by Gary Woodfine (see all)