fbpx

Introduction

MYSQL is a software, with MySQL server at its core, and a lot of utility programs, that helps is managing and administration of database.

For example, let say you want to create a new database, you send a message to the MySQL server that says, for instance, “create a new database and call it newdb.” The MySQL server then creates a subdirectory in its data directory, names the new subdirectory newdb, and puts the necessary files with the required format into the newdb subdirectory. In the same manner, to add data to that database, you send a message to the MySQL server, giving it the data and telling it where you want the data to be added.

For more information on MySQL please check out this article.

Let Us Begin Our Installation of MySQL

To get the latest version of  MySQL, we’ll have to add the repository, then install MySQL, secure it and test it.

You can either follow the video below or go along with the written steps right below it.

Step 1 — Adding the MySQL Software Repository

Open the MySQL download page.

Go to the APT Repository page.

Click on the Download button.

Then right-click on the No thanks, just start my download.

And select Copy Link Address, open up Notepad and paste it.

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

  • cd /tmp

Download the file using curl, remembering to paste the address you just copied in place of the highlighted portion below:

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

The file should now be downloaded in our current directory. List the files to make sure:

  • ls
Output
mysql-apt-config_0.8.3-1_all.deb
. . .

Now we’re ready to install:

  • sudo dpkg -i mysql-apt-config*

dpkg is used to install, remove, and inspect .deb software packages. The -i flag indicates that we’d like to install from the specified file.

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

  • sudo apt-get update

Let’s also clean up after ourselves and delete the file we downloaded:

  • rm mysql-apt-config*

The repository part is done, now the easier part. Soldiers! Charge!

Step 2 — Installing MySQL

We can now use apt-get to install the latest MySQL server package:

  • sudo apt-get install mysql-server

apt-get looks for the mysql-server packages and will see our newly downloaded latest MySQL package and will begin installing it.

MySQL should be installed and running now. Let’s check using systemctl:

  • systemctl status mysql
Output
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2017-04-05 19:28:37 UTC; 3min 42s ago
 Main PID: 8760 (mysqld)
   CGroup: /system.slice/mysql.service
           └─8760 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

The Active: active (running) line means MySQL is installed and running. Now we’ll make the installation a little more secure.

Step 3 — Securing MySQL

MySQL comes with a command we can use to perform a few security-related updates on our new install. Let’s run it now:

  • mysql_secure_installation

Here you can configure MySQL as per your need.

Step 4 – Testing MySQL

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

  • mysqladmin -u root -p version

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

The output will let us know what version of the MySQL server is running, its uptime, and some other status information:

Output
mysqladmin  Ver 8.42 Distrib 5.7.17, for Linux on x86_64
Copyright (c) 2000, 2016, 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      5.7.17
Protocol version    10
Connection      Localhost via UNIX socket
UNIX socket     /var/run/mysqld/mysqld.sock
Uptime:         58 min 28 sec

Threads: 1  Questions: 10  Slow queries: 0  Opens: 113  Flush tables: 1  Open tables: 106  Queries per second avg: 0.002

If you see this, that means you successfully followed through and now have a working MySQL on your server.

Congratulations.

Categories: Tutorials

0 Comments

Leave a Reply

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