Install MySQL Latest Versions on Ubuntu 16.04 LTS Server

MySQL is still a popular database server… however, the default open source database server on the majority of Linux systems is MariaDB… Some webmasters still find MySQL very useful and are sticking with it..

The MySQL package version that comes with Ubuntu default repositories is not the latest version… If you need to install the latest version of MySQL database, you may want to install its repository in Ubuntu.. In many cases, the most up-to-date packages are available from the package own repository and not from Ubuntu… So if you need to get the latest versions of MySQL, the steps below is a great place to start…

This brief tutorial shows students and new users how to easily add MySQL database repository in order to install the most up-to-date version.

Step 1: Add MySQL Repository on Ubuntu

Adding MySQL repository will allow Ubuntu 16.04 LTS access the most up-to-date MySQL packages…. The steps below shows you how to add the repository..

The repository package for Ubuntu and others can be downloaded from the link below…

https://dev.mysql.com/downloads/repo/apt/

Visit the download page and look for Ubuntu / Debian (Architecture Independent), DEB Package. The click the Download button to get the repository package…

ubuntu mysql repository

Of you can use wget commands below to download via the command line terminal.. however, you must change the version number to the latest..

cd /tmp/ && wget https://dev.mysql.com/get/mysql-apt-config_0.8.9-1_all.deb

Step 2: Installing MySQL Repository

After downloading the repository package, run the commands below to install it.

sudo dpkg -i mysql-apt-config_0.8.9-1_all.deb

During the installation, you’ll be presented with a configuration screen to choose which version of MySQL to install, as well as the option to install its repositories. The default option will add a repository for the default stable version of MySQL.

This is the option we want.. so select the default. Scroll down the list and click Ok to install the repository.

ubuntu mysql repository

After the repository is added, all you have to do is update and install MySQL.

A new apt .list file should be created at /etc/apt/sources.list.d/mysql.list with the content below:

### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out entries below, but any other modifications may be lost.
# Use command 'dpkg-reconfigure mysql-apt-config' as root for modifications.
deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-apt-config
deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-5.7
deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-tools
#deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-tools-preview
deb-src http://repo.mysql.com/apt/ubuntu/ xenial mysql-5.7
richard@ubuntu1604:/etc/apt/sources.list.d$

Step 3: Installing MySQL Server

Now that the repository is added, run the commands below to install MysQL.

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

Doing the above will install MySQL from the repository with the latest packages for it.

After installing, you may want to run the commands below to secure MySQL.

sudo mysql_secure_installation

This will prompt you for the current root password you created when installing the software. You can follow the guide below to complete the setup.

Enter password for user root: ENTER ROOT PASSWORD
Press y|Y for Yes, any other key for No: n
Change the password for root ? n
Remove anonymous users? y
Disallow root login remotely? y
Remove test database and access to it? y
Reload privilege tables now? y

After that, you’re all done. This is how one installs MySQL latest versions on Ubuntu..

Enjoy!

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.21 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.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

You may also like the post below:

Install Magento on Ubuntu 17.04 / 17.20 with Apache2, MariaDB, PHP and Let’s Encrypt SSL

 

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.