How to Install MySQL 8.0 in Ubuntu 18.04 ?
MySQL is an open-source relational database server tool for Linux/Windows operating systems. It is widely used in modern web-based technology. It is used with many open sources based on the LAMP stack. MySQL is the M in LAMP development. It is used to store and retrieve data in the database.
We will learn instruction step-by-step in this tutorial to install mysql8 on how to install MySQL on Ubuntu 18.04.
- A system running Ubuntu 18.04
- Sudo account privileges
- Terminal window (ctrl+alt+T)
- you’re installing on a local system
- The APT package manager (installed by default)
Installing MySQL in Ubuntu Using Terminal (ctrl+alt+T)
These instructions assume you’re installing a local system.
Step 1: Get the MySQL Repositories
Your installation of Ubuntu 18.04 may not have access to MySQL repositories.
To download the latest repositories, enter the following code in your terminal window:
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.11-1_all.deb
If your system has an active internet connection, Then the system should acknowledge by downloading the .deb configuration file from the server. A progress bar will tell you how much amount of the files have been downloaded and also let you know when the download is completed. You can refer the below screen on how it works :
Also, it’s possible that a newer apt-config file has been published since this document was written. You can find the link to the latest file on the MySQL downloads page.
You can also verify that whether the deb file has been downloaded in your local system or not by using the following command.
NOTE: The -c option will direct the system to resume the download if it’s interrupted.
Let’s also clean up after ourselves and delete the file we downloaded:
Step 2: Install MySQL Repositories
To install and enable MySQL repositories, enter the command:
We will be using the dpkg command to install the package.
sudo dpkg -i mysql-apt-config_0.8.11-1_all.deb
There will be some launching screens just like the below screen will come as an installation configuration tool. It will present options to you for which MySQL version you want to install.
Leave the default settings as it is and click OK, unless you’re an advanced user and have a specific reason to change them.
Refresh the Repositories
Every time when you’re adding/installing new packages, you should update repository listings to ensure you are installing the latest release.
In the terminal, enter the following:
sudo apt-get update
The system should take a few moments and refresh the repository cache.
NOTE: You won’t be able to use Ubuntu’s native repositories to install MySQL software until this repository is disabled.
Step 3: Install MySQL on Ubuntu 18.04
To install MySQL on Ubuntu, run the command:
sudo apt-get install mysql-server
Enter your administrator credentials, and the system will install the MySQL server package, client packages, and database common files.
The installation will prompt you to enter and confirm a root user and password for the MySQL database.
This password grants total access to the database, so it should be secure and private.
Next, the installer will display a notice about a new authentication method. The newer authentication is more secure but may cause compatibility problems with older MySQL clients.
Click OK, then on the next screen select the authentication method you want to use, then click OK again.
Step 4: Set up MySQL Security
To install the MySQL security script, type the below command, and press the enter button:
The system will ask for the sudo user Password.
Validate Password Plugin
This plugin checks to make sure that any new passwords are strong/complex enough. Type y to enable or n to disable. The choice is yours, but enabling this plugin is more secure.
The Validate Password plugin has three settings for passwords:
- LOW with Length >= 8
- MEDIUM with Length >= 8, numeric, mixed case, and special characters
- STRONG with Length >= 8, numeric, mixed case, special characters, and dictionary
Change Root Password
Next, is a chance again to change your root password. Type y to change the password, or n to keep the same password.
If you do change the password, it will need to follow any requirements you configured in Step 5a.
Configure MySQL Security
The system will prompt you for the following security features. It is recommended that you confirm (type y) all options unless you have a reason to keep them disabled.
- Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
- Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
- Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
You can see all the above steps in the below screen :
Step 5: Start, Stop, or Check Status of MySQL Service
In Ubuntu, the MySQL service should start automatically.
Use the below commands to verify it:
sudo service mysql status OR sudo systemctl status mysql
To stop the service, use the below command :
sudo service mysql stop
To start the service, use the below command :
sudo service mysql start
If for any reason MySQL service isn’t auto-started, use the commands below to start and enable it to start at system boot time, as follows.
$ sudo systemctl status mysql $ sudo systemctl enable mysql
Step 6: Launch MySQL Shell to Enter Commands
Many MySQL commands can be entered from the MySQL command shell. It helps in issuing commands directly to the MySQL services.
Run the below command to Launch MySQL shell :
sudo mysql -u root -p
Installing MySQL on Ubuntu 18.04 was awesome!
Now, you should have MySQL 8 installed on your Ubuntu system, with basic security controls.
You can run additional database tasks through the MySQL shell, as described in Step 7. Or, you can install other plugins or tools to manage your database.
Now you have learned how to install MySQL 8.0 on Ubuntu 18.04. Now, you can play around with mysql8. You can create a database, delete a database, and can do the Insert, Update and Delete, etc operations.
Thanks for your time reading. If you face any problem or any feedback, please leave a comment below.
Popular tools for managing MySQL on Ubuntu are phpMyAdmin and MySQL Workbench.