VPS Series: What Is MySQL And How Do You Download It On CentOS7?

If you’re using Linux, there’s a high likelihood that you depend on a database. MySQL, an Oracle developed program started in 1995, is a database management system that uses a query system.

A database system is a way to manage information. The information could be from anywhere. You might need to manage research data for school or have to keep business records and customer information in a way that’s easy to access. Sales reports, computer data, student grades…even sports statistics rely on a database to manage.

For this information, MySQL is an easy to use program that allows you to review and work with collected data.

You can run MySQL on almost any system platform. It has cross-platform, replication, and Unicode support, triggers, cursors, and more. Most Linux users want it, but the built-in software installs MariaDB, which is a version of MySQL.

If you want the real thing, you’ll need to add a custom repository made by MySQL. Once you’ve done this, installing the database is an easy task. You will need an active internet connection and VPS that runs CentOS7.

Let’s get started.

How to install MySQL on CentOS7

1. Download The Yum Repository

Go to the MySQL Yum repository page and click the download button next to Red Hat Enterprise Linux 7. On the page that pops up, there will be a button that says “No thanks, just start my download” at the bottom. Click that button. Then click the “Copy Link” button.

You’ll now either SSH (secure shell) or log in to your CentOS7 machine. Type “wget” into the bash shell to make sure it’s installed. If not, you’ll need to enter the command yum install -y wget.

The wget download should only take a minute. Once wget downloads, you can download the MySQL repository file.

Choose a folder where you want to save the download and type wget <download link here>.

Once it downloads and saves the file to your device, you’re ready for the next step.

2. Add The MySQL Yum Repository

You’re now able to add the new repository to your Yum program. To do so, you’ll need to enter sudo rpm -Uvh <package name here>.

After this, you’ll receive a prompt to enter your user account’s password. Do this and the repository will get added to your Yum program.

3. Install MySQL

The installation process itself is pretty straightforward once you’ve downloaded and added the actual MySQL repositories. Use the command sudo yum install mysql-community-server.

Press the “y” button to accept the results of the file’s GPG verification and your installation will start immediately.

4. Set Up MySQL

The next step is necessary. You have to start the server and set a root password. This is also a fairly easy process, but it’s still more involved than the previous steps.

First, start MySQL with sudo systemctl start mysqld.service.

When you start MySQL for the first time, it creates a root user and random password. You can find the password in the error log file with sudo grep ‘temporary password’ /var/log/mysqld.log.

The output contains the password that you’ll need to log in. Log in as the root user and use mysql -uroot -p to enter the MySQL query shell.

Enter the password you received earlier. You’ll need to change the password, making it something that you can remember, using  ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘mypassword’;.

The password, like those you use for bank and email accounts, must contain at least one uppercase letter, a lowercase letter, a special character (!@#$% etc) and a number. Try to stay away from passwords with your spouse’s or kid’s name, as those are the first ones hackers try when gaining access to a system.

Additional Information

There are some other commands you’ll need to familiarize yourself with while using MySQL.

If you ever need or want to upgrade the program, it’s easy to do so. Simply enter sudo yum update mysql-server.

This updates the entire packet through Yum. When you update the entire system using Yum this process will also take place. MySQL will automatically reset once you upgrade. You’ll need to make sure that the plugins are all compatible with the update by running “mysql_upgrade”.

If you’re unsure about what commands to use with MySQL, there’s a way to view them all. Enter /h to pull up the help menu. Some of the more important commands are:

  • clear (\c) Clears commands. You’ll use this one the most when you first start using MySQL.
  • connect (\r) Reconnects to the server. Optional arguments are db and host.
  • delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.
  • edit (\e) Edit commands with $EDITOR.
  • ego (\G) Send commands to the mysql server and displays results vertically.
  • exit (\q) Exit mysql. It’s the same as quit.
  • go (\g) Sends commands to the mysql server.

There are more that will show up once you enter /h. This tool tells you every command you’ll need to know when using MySQL. When you first start using the program, it’s recommended that you create a cheat sheet so that you can easily access the commands until you memorize them.

More Information About Running Your Website

Now that you know how to install MySQL, you’re probably wondering what else you can do with your computer. Do you want to ensure your online privacy and the security of your customers? We offer VPS and SSL services along with world-class customer service.

Contact our team today to learn how we can help your website succeed