How to install MySQL on Ubuntu

What is MySQL?

MySQL is a popular and widely used free open source database. In case you are new to using database available options, MySQL is a good choice as it is easy to install as well as operate.

Installing MySQL in Ubuntu different from installing it in Windows therefore in this article, I will talk about the installation of MySQL in Ubuntu.

You may also so be required to install other important software or packages as well to successfully use MySQL. For instance, PHP extensions are necessary for MySQL to work properly in Ubuntu.

Installation of MySQL in Ubuntu:

Following is a step by step information about successfully installing MySQL in Ubuntu. for a successful installation, you will require a 16.04 server on Ubuntu, a firewall and a non-root user.

Step 1: Installation of MySQL

The APT package repository is included in the latest version of MySQL by default which is 5.7 (while, I am writing this article). You can install it on Ubuntu 16.04 by updating the package on your server and then install the package with is available by default with APT.

Another important thing for a successful installation is to get a sudo apt update. You need to create a secure root password to complete the installation properly. Make sure to remember that password because it will be required later on.

Command:

sudo apt-get update
sudo apt-get install mysql-server

Step 2: MySQL configuration

In this step, you will first be required to run the security script for installation. This may alternate a few default options which are not secure such as sample users and remote root logins. In case you are using an older version of MySQL, you will be required to manually start the data directory however if you have the latest version it will be initialized automatically.

The next thing which you need to focus on is running the security step and for this, you will need the root password you used in step 1. To accept all the default options for subsequent questions you can press ‘Y’ and ‘ENTER’ key from your keyboard. The only exception in hair will be the question regarding the change in the root password. Since you set up this password in step and you do not need to change this as of now.

Command:  mysql_secure_installation

Step 3: Initializing data directory of MySQL

The next step is to initialize the data directory of MySQL. If you have any version before 5.7.6 then you would have to use to initiate data directory and for versions after 5.7.6 you can use mysqld –initialize. In case you installed MySQL from Debian distribution then all these configurations will be automatic and if you try to run commands you will experience errors.

Commands:

For versions before 5.7.6:  mysql_install_db
For versions after 5.7.6: mysqld –initialize

After these three steps, you will be able to MySQL successfully in Ubuntu.

Add a Comment

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