MySQL is a database management system. Installing MySQL on the CentOS 7 server does not work as easily as on CentOS 6, but can be done after adding a new software repository.
CentOS in version 7 prefers the MariaDB package developed by developers of MySQL. MariaDB is a package that is provided as a replacement for MySQL and can be installed directly from the official repository. If you want to use MariaDB, it’s enough to type the following command after you connect to the server (connect to the server over SSH):
——
yum install mysql
——
And the installation of MariaDB will start, just like in the picture below. You will only need to follow the installation process, and confirm the steps by pressing the Y key when prompted.
If you do not want to use MariaDB, you can install MySQL on CentOS 7 using this guide:
How to install MySQL on a CentOS 7 server?
First, you need to add a new software repository that contains the necessary MySQL software packages. To access the repository, first you need to visit this page to download the necessary files to add a new software source:
——
https://dev.mysql.com/downloads/repo/yum/
——
There are several files here:
For CentOS 7 it is necessary to download the file Red Hat Enterprise Linux 7 / Oracle Linux 7, and then click on the Download button in that row. Note that under each Download button you have MD5 for each package that can be downloaded here. You will need this later to verify that the download package is correct.
The following page will show options for signing in to an account or creating a new account. If you do not have an account or do not want to log in or register, just click on No thanks, just start my download to download the file or copy this link to download the file (copy the link because we will need to download it via wget).
Here it is necessary now to login on to your server because we will start downloading the file via wget command. When you are logged in via SSH connection and console, type the following:
——
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
——
Note that this link behind the wget command should be the link that you copied from the Download page, it may not be the same over time as the link that stands in the example we wrote above.
Check md5sum immediately after downloading the package:
——
md5sum mysql80-community-release-el7-1.noarch.rpm
——
The numbers need to be exactly matched, otherwise, the package is not correct. The numbers to be compared are shown in the image in red and blue:
If the site numbers and numbers from your console are correctly matched, we can continue the installation:
——
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
——
This package has added two new MySQL yum repositories, so now we can also install MySQL:
——
yum install mysql-server
——
It is only necessary to monitor the installation and confirm when requested. To confirm, press the Y button on the keyboard.
Start MySQL after installation on CentOS 7
It is necessary to run mysqld which is the MySQL daemon. Type the following in the console:
——
systemctl start mysqld
——
Check also if this command has done its job:
——
systemctl status mysqld
——
If “Active: active (running)” is printed, it means it works. Here’s how it should look:
Configuring MySQL on CentOS 7 server
MySQL brings some steps for improved security. For this, you need to have a password that was created automatically during the installation. This password is located in /var/log/mysqld.log so we can get it out like this:
——
grep 'temporary password' /var/log/mysqld.log
——
Copy the password you find, because you will need it soon. Now we can also start a step to improve security:
——
mysql_secure_installation
——
The password will be requested here, so you can enter it. The following notification will be printed indicating that the old temporary password has expired and that you need to set a new one:
——
The existing password for the user account root has expired. Please set a new password.
——
Enter a new password. Remember that the password should have at least one small letter, one large, one special character and a number, and a minimum of 12 characters. In the further process, you will also get a few questions, so if you are not sure, press Enter as the answer to each question. Enter will select the default option.
Testing the installed MySQL
MySQL testing can also be done by a simple checking of the version as a root user:
——
mysqladmin -u root -p version
——
If you get the next printout:
——
[root@server-oblak ~]# mysqladmin -u root -p version Enter password: mysqladmin Ver 8.0.12 for 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.12 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/lib/mysql/mysql.sock Uptime: 21 min 21 sec Threads: 2 Questions: 7 Slow queries: 0 Opens: 121 Flush tables: 2 Open tables: 97 Queries per second avg: 0.005
——
This means that with your MySQL everything is fine and that MySQL is installed on your CentOS 7 server.
Free CentOS 7 operating system setup
CentOS is a free operating system and as such we can install it for you on any VPS or Dedicated server. You just need to let us know that you need it CentOS 7. The installation is free, as well as for other operating systems that you can get on demand.
If you decide to use a server only with the operating system, keep in mind that it is necessary to know the actions that you will need to update and maintain your server. E.g, How to install WordPress on CentOS 7 server can be complicated if you have never worked on a server before and have accessed it via SSH connection. In case you are not in this, we recommend using the WHM/cPanel server management solution.
0 Comments