How to install the latest MySQL on Ubuntu 18.04

Introduction

MySQL is a well-known open source database management system used to store and retrieve data from various popular applications. MySQL is M in the LAMP stack. It is a set of commonly used open source software, including Linux, Apache web server and PHP programming language.

In order to use newly released features, sometimes it is necessary to install a newer version of MySQL than the one provided by the Linux distribution. Conveniently, MySQL developers maintain their own software repository, which we can use to easily install the latest version and keep it up to date.

To install the latest version of MySQL, we will add this repository, install the MySQL software itself, protect the installation, and finally we will test whether MySQL is running and respond to commands.

Preparation

Before starting this tutorial, you need to:

Step 1-Add MySQL Software Library

MySQL developers provide a .deb package for handling configuration and installation of the official MySQL software repository. Once the repository is set up, we can use Ubuntu's standard apt command to install the software. We will use curl to download this .deb file, and then use the dpkg command to install it.

First, load MySQL download page in a web browser. Find the "Download" button in the lower right corner, and click the next page. This page will prompt you to log in or register for an Oracle web account. We can skip this and instead look for links that say no need, just start my download**. Right-click the link and select "Copy Link Address" (The wording of this option may be different, depending on your browser).

Now we are going to download the file. On your server, move to a directory where you can write:

cd /tmp

Use curl to download the file, remember to paste the address you just copied instead of the highlighted part below:

curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.10-1_all.deb

We need to pass two command line flags curl. -O instructs curl to output to a file instead of standard output. The L flag makes curl follow HTTP redirects, which is necessary in this case because the address we copied actually redirects us to another location before the file is downloaded.

The file should now be downloaded to our current directory. List the files to ensure:

ls

You should see the file name listed:

mysql-apt-config_0.8.10-1_all.deb
...

Now we are ready to install:

sudo dpkg -i mysql-apt-config*

dpkg is used to install, delete and check the .deb package. The -i flag indicates that we want to install from the specified file.

During the installation process, you will see a configuration screen where you can specify your preferred MySQL version, as well as options for installing repositories for other MySQL-related tools. The default value will add the repository information of the latest stable version of MySQL, but nothing else. This is what we want, so use the down arrow to navigate to the Ok menu option and hit ENTER.

The package will now finish adding the repository. Flush the apt package cache to make new packages available:

sudo apt update

Let's clean up and delete the files we downloaded by ourselves:

rm mysql-apt-config*

Now that we have added the MySQL repository, we are ready to install the actual MySQL server software. If you need to update the configuration of these repositories, just run sudo dpkg-reconfigure mysql-apt-config, select the new option, and then sudo apt update to refresh the package cache.

Step 2-Install MySQL

With the repository added and recently updated using our package cache, we can now install the latest MySQL server package using apt:

sudo apt install mysql-server

apt will look at all available mysql-server packages and determine that the packages provided by MySQL are the latest and best candidates. It will then calculate the package dependencies and ask you to approve the installation. Type y and then ENTER. The software will install.

The system will ask you to set the root password during the configuration phase of the installation. Be sure to choose a secure password. After entering it twice and hitting ENTER, you will be prompted to configure the authentication plugin. It is recommended to **use **the default "Encrypt with strong password", so please click ENTER to select it. The installation process will continue to completion.

MySQL should now be installed and running. Let's check the use of systemctl:

systemctl status mysql
● mysql.service - MySQL Community Server
 Loaded:loaded(/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
 Active:active(running) since Thu 2018-07-1217:46:42 UTC; 17s ago
  Docs: man:mysqld(8)
   http://dev.mysql.com/doc/refman/en/using-systemd.html
 Main PID:7918(mysqld)
 Status:"SERVER_OPERATING"
 Tasks:37(limit:1152)
 CGroup:/system.slice/mysql.service
   └─7918/usr/sbin/mysqld

The Active: active (running) line means that MySQL is installed and running. Now we will make the installation more secure.

Step 3-Secure MySQL

MySQL comes with a command that we can use to perform some security-related updates on the new installation. Let's run it now:

mysql_secure_installation

This will ask you for the MySQL root password you set during installation. Type and press ENTER. Now we will answer a series of yes or no prompts. Let's see:

First, we were asked about Verify Password Plugin, which is a plugin that can automatically enforce certain password strength rules for MySQL users. Enabling this feature is a decision you need to make based on your personal security needs. Enter y and ENTER to enable it, or just hit ENTER to skip it. If enabled, the system will also prompt you to select a level from 0-2 to determine the strictness of password verification. Select a number and click ENTER to continue.

Next, you will be asked if you want to change the root password. Since we just created the password when installing MySQL, we can safely skip this. Click ENTER to continue without updating the password.

The remaining prompts can be answered yes. The system will ask you whether to delete the anonymous MySQL user, prohibit remote root login, delete the test database, and reload the permission table to ensure that the previous changes take effect. These are all good ideas. Type y and click ENTER for each item.

After answering all prompts, the script will exit. Now our MySQL installation is reasonably safe. Let's test it again by running the client connected to the server and return some information.

Step 4-Test MySQL

mysqladmin is a command line management client for MySQL. We will use it to connect to the server and output some version and status information:

mysqladmin -u root -p version

The -u root part tells mysqladmin to log in as the MySQL root user, -p instructs the client to ask for a password, this version is the actual command we want to run.

The output will tell us which version of the MySQL server is running, uptime, and some other status information:

mysqladmin  Ver 8.0.11for Linux on x86_64(MySQL Community Server - GPL)Copyright(c)2000,2018, Oracle and/or its affiliates. All rights reserved.
​
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
​
Server version      8.0.11
Protocol version    10
Connection      Localhost via UNIX socket
UNIX socket     /var/run/mysqld/mysqld.sock
Uptime:2 min 21 sec
​
Threads:2  Questions:10  Slow queries:0  Opens:136  Flush tables:2  Open tables:112  Queries per second avg:0.070

If you receive similar output, congratulations! You have successfully installed and protected the latest MySQL server.

in conclusion

You have now completed the basic installation of the latest version of MySQL, which should work for many popular applications.

For more Ubuntu tutorials, please go to [Tencent Cloud + Community] (https://cloud.tencent.com/developer?from=10680) to learn more.

Reference: "How To Install the Latest MySQL on Ubuntu 18.04"

Recommended Posts

How to install the latest MySQL on Ubuntu 18.04
How to install MySQL on Ubuntu 14.04
How to install MySQL on Ubuntu 18.04 (linux)
How to install Ruby on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04
How to install KVM on Ubuntu 18.04
How to install KVM on Ubuntu 20.04
How to install opencv3.0.0 on ubuntu14.04
How to install Prometheus on Ubuntu 16.04
How to install Jenkins on Ubuntu 18.04
How to install R on Ubuntu 20.04
How to install Moodle on Ubuntu 16.04
How to install Solr 5.2.1 on Ubuntu 14.04
How to install Teamviewer on Ubuntu 16.04
How to install MariaDB on Ubuntu 20.04
How to install Nginx on Ubuntu 20.04
How to install Mono on Ubuntu 20.04
How to install Go on Ubuntu 20.04
How to install mysql in Ubuntu 14.04
How to install Nginx on Ubuntu 16.04
How to install OpenCV on Ubuntu 20.04
How to install Spotify on Ubuntu 20.04
How to install Postman on Ubuntu 18.04
How to install Go 1.6 on Ubuntu 16.04
How to install Go on Ubuntu 18.04
How to install PostgreSQL on Ubuntu 20.04
How to install VLC on Ubuntu 18.04
How to install TeamViewer on Ubuntu 20.04
How to install Webmin on Ubuntu 20.04
How to install and use MySQL Workbench on Ubuntu 18.04
Install the latest Python 3.6 version on Ubuntu
How to install Docker Compose on Ubuntu 18.04
How to install Ubuntu on Raspberry Pi
How to install Bacula Server on Ubuntu 14.04
Install mysql on Ubuntu 14.04
How to install Apache Maven on Ubuntu 20.04
How to install Python2 on Ubuntu20.04 ubuntu/focal64
How to install JDK and Mysql on Ubuntu 18.04 linux system
How to install GCC compiler on Ubuntu 18.04
How to install Graylog 1.x on Ubuntu 14.04.