Select Page


MySQL is a outstanding open supply database control gadget used to retailer and retrieve information for all kinds of common programs. MySQL is the M within the LAMP stack, a regularly used set of open supply instrument that still comprises Linux, the Apache information superhighway server, and the PHP programming language.

With the intention to use newly launched options, it is every now and then vital to put in a extra up-to-date model of MySQL than that equipped via your Linux distribution. With ease, the MySQL builders deal with their very own instrument repository we will be able to use to simply set up the most recent model and stay it up-to-the-minute.

To put in the most recent model of MySQL, we will upload this repository, set up the MySQL instrument itself, safe the set up, and in any case we will take a look at that MySQL is operating and responding to instructions.

Must haves

Prior to beginning this educational, you are going to want:

Step 1 — Including the MySQL Instrument Repository

The MySQL builders supply a .deb bundle that handles configuring and putting in the respectable MySQL instrument repositories. As soon as the repositories are arrange, we will be capable of use Ubuntu’s usual apt command to put in the instrument. We’re going to obtain this .deb record with curl after which set up it with the dpkg command.

First, load the MySQL download page on your information superhighway browser. In finding the Obtain button within the lower-right nook and click on via to the following web page. This web page will urged you to log in or join an Oracle information superhighway account. We will skip that and as a substitute search for the hyperlink that claims No thank you, simply get started my obtain. Proper-click the hyperlink and make a selection Replica Hyperlink Cope with (this feature could also be worded another way, relying for your browser).

Now we are going to obtain the record. To your server, transfer to a listing you’ll be able to write to:

Obtain the record utilizing curl, remembering to stick the cope with you simply copied instead of the highlighted portion underneath:

  • curl -OL

We wish to go two command line flags to curl. -O instructs curl to output to a record as a substitute of usual output. The L flag makes curl apply HTTP redirects, vital on this case for the reason that cope with we copied in fact redirects us to some other location prior to the record downloads.

The record will have to now be downloaded in our present listing. Checklist the recordsdata to verify:

You will have to see the filename indexed:


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

Now we are able to put in:

  • sudo dpkg -i mysql-apt-config*

dpkg is used to put in, take away, and investigate cross-check .deb instrument applications. The -i flag signifies that we might like to put in from the required record.

All through the set up, you’ll be able to be introduced with a configuration display screen the place you’ll be able to specify which model of MySQL you would choose, at the side of an method to set up repositories for different MySQL-related equipment. The defaults will upload the repository data for the most recent solid model of MySQL and not anything else. That is what we wish, so use the down arrow to navigate to the Adequate menu possibility and hit ENTER.

The bundle will now end including the repository. Refresh your apt bundle cache to make the brand new instrument applications to be had:

Let’s additionally blank up after ourselves and delete the record we downloaded:

Now that we have added the MySQL repositories, we are able to put in the real MySQL server instrument. In case you ever wish to replace the configuration of those repositories, simply run sudo dpkg-reconfigure mysql-apt-config, make a selection new choices, after which sudo apt replace to refresh your bundle cache.

Step 2 — Putting in MySQL

Having added the repository and with our bundle cache freshly up to date, we will be able to now use apt to put in the most recent MySQL server bundle:

  • sudo apt set up mysql-server

apt will have a look at all to be had mysql-server applications and resolve that the MySQL equipped bundle is the latest and perfect candidate. It’s going to then calculate bundle dependencies and ask you to approve the set up. Kind y then ENTER. The instrument will set up.

You’re going to be requested to set a root password all over the configuration segment of the set up. Ensure that to make a choice a safe password. After you input it two times and hit ENTER, you are going to be brought about to configure an authentication plugin. The default of Use Robust Password Encryption is really useful, so hit ENTER to make a choice it. The set up procedure will proceed till crowning glory.

MySQL will have to now be put in and operating. Let’s test utilizing systemctl:


● mysql.provider - MySQL Neighborhood Server Loaded: loaded (/lib/systemd/gadget/mysql.provider; enabled; supplier preset: enabled) Energetic: lively (operating) since Thu 2018-07-12 17:46:42 UTC; 17s in the past Doctors: guy:mysqld(8) Major PID: 7918 (mysqld) Standing: "SERVER_OPERATING" Duties: 37 (restrict: 1152) CGroup: /gadget.slice/mysql.provider └─7918 /usr/sbin/mysqld

The Energetic: lively (operating) line method MySQL is put in and operating. Now we will make the set up a bit extra safe.

Step 3 — Securing MySQL

MySQL comes with a command we will be able to use to accomplish a couple of security-related updates on our new set up. Let’s run it now:

  • mysql_secure_installation

This may ask you for the MySQL root password that you simply set all over set up. Kind it in and press ENTER. Now we will resolution a chain of sure or no activates. Let’s undergo them:

First, we’re requested concerning the validate password plugin, a plugin that may mechanically put into effect positive password power laws on your MySQL customers. Enabling it is a choice you’ll be able to wish to make in response to your own safety wishes. Kind y and ENTER to allow it, or simply hit ENTER to skip it. If enabled, you are going to even be brought about to make a choice a degree from 0–2 for a way strict the password validation will probably be. Make a choice a host and hit ENTER to proceed.

Subsequent you’ll be able to be requested if you wish to alternate the root password. Since we simply created the password after we put in MySQL, we will be able to safely skip this. Hit ENTER to proceed with out updating the password.

The remainder of the activates will also be responded sure. You’re going to be requested about eliminating the nameless MySQL person, disallowing far off root login, eliminating the take a look at database, and reloading privilege tables to make sure the former adjustments take impact correctly. Those are all a good suggestion. Kind y and hit ENTER for each and every.

The script will go out in any case the activates are responded. Now our MySQL set up is moderately secured. Let’s take a look at it once more via operating a shopper that connects to the server and returns some data.

Step 4 – Trying out MySQL

mysqladmin is a command line administrative consumer for MySQL. We’re going to use it to hook up with the server and output some model and standing data:

  • mysqladmin -u root -p model

The -u root portion tells mysqladmin to log in because the MySQL root person, -p instructs the customer to invite for a password, and model is the real command we need to run.

The output will tell us what model of the MySQL server is operating, its uptime, and a few different standing data:


mysqladmin Ver 8.0.11 for Linux on x86_64 (MySQL Neighborhood Server - GPL) Copyright (c) 2000, 2018, Oracle and/or its associates. All rights reserved. Oracle is a registered trademark of Oracle Company and/or its associates. Different names could also be logos in their respective homeowners. Server model 8.0.11 Protocol model 10 Connection Localhost by way of UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 2 min 21 sec Threads: 2 Questions: 10 Sluggish queries: 0 Opens: 136 Flush tables: 2 Open tables: 112 Queries consistent with 2nd avg: 0.070

In case you won an identical output, congrats! You might have effectively put in the most recent MySQL server and secured it.


You might have now finished a elementary set up of the most recent model of MySQL, which will have to paintings for lots of common programs. When you’ve got extra complex wishes it’s possible you’ll proceed with any other configuration duties:

  • In case you’d like a graphical interface for administering your MySQL server, phpMyAdmin is a well-liked web-based resolution. Our educational How To Install and Secure phpMyAdmin can get you began.
  • Recently, your database is handiest out there to programs operating at the identical server. Now and again you’ll need separate database and alertness servers, for efficiency and garage causes. Check out How To Configure SSL/TLS for MySQL to learn to arrange MySQL for safe get admission to from different servers.
  • Some other commonplace configuration is to modify the listing the place MySQL retail outlets its information. You’ll wish to do that if you wish to have your information saved on a distinct garage tool than the default listing. That is coated in How To Move a MySQL Data Directory to a New Location.