In continuation to our previous tutorial where we cleared all the basic concepts related to MySQL and MariaDB.
In this tutorial we are going to learn how to install MySQL on CentOS 7.
Prerequisites:
For following tutorial you will need CentOS 7 with a non-root user with sudo privileges.
Sudo privileges : Sudo stands for Super User Do. If we prefix any Linux command with sudo then that command will be executed with higher privileges. In simple words we can say that it helps the user to run a command which is run in an access denied privilege area.
1 . Download the rpm packages:
CentOS 7 is Linux Flavor and it uses Yum package manager to download new software inside it. Since we are trying to install the latest version of MySQL we will require the rpm packages for that. These rpm packages contains the list of all the repos which are required by the yum package manager to install the software. Follow the below link for downloading the rpm packages:
Go to Chrome == > MySQL ==> Downloads ==> Yum Repository ==>
Select the latest version of the MySQL i.e. Version of CentOS 7 Version 7 Red Hat Linux 7 version ==> Download ==>
A prompt will appear asking for login ==> ignore it ==> select No, thanks just start my download ==> Right click and copy link address.
Then run wget command as follows:
Wgate is a non-interactive downloader i.e. it helps in downloading the files in an no-interactive way. It is a free function. we can retrieve files from HTTP, HTTPS and FTP Protocol.
Meaning of non-interactive i.e. this command can work in the background even if the user is not present or logged in. So it does not require the constant presence of the user at the time of data transfer meanwhile Wget will finish the work.
Save the rpm files, then we can verify for md5sum
It is verified that the file is not corrupted so we start installing MySQL server. The output will be:
Compare this output with your RPM MD5. It should be same.
Now that we have verified the output, let’s start installing the MySQL.
It adds two new yum repositories we will use them for installation.
It will prompt for continuation . Press Y for continuation. It will also prompt for accepting a GPG key. Press Y and finish the installation.
Press ‘Y” and installation will start as follows:
It will then prompt for GPG key. Press : ‘Y” following will be the output:
Start the daemon mysqld using following command
Systemctl is used when we want to check the status of the system services and also want to enable, start, Restart, Reload, stop the system services like MySQL.
Following command is used for checking whether we have successfully started the daemon or not.
sudo systemctl status mysqld
The output will be Active if the MySQL has started successfully.
Final line should show this:
MySQL has a default behaviour of starting at the time of boot when it is installed. Using following command we can change its default behaviour.
sudo systemctl disable mysqld
It creates a temporary password at the time of installation process in a log file. Take that password from log file using grep command.
Log File : These are stored in the folder /var/logs. This folder contains large no. of files and we can get information of each application.
Grep command is used to print the lines which match the pattern or for finding the text in a file.
Output :
This password will be required in the next step for securing the installation and then you need to set a new password. The default password policy has strict validations like the password should have 12 characters formed by combination of uppercase, lower case letters, number and a special character.
3. MySQL Configuration :
In this step we need to change some of the default options which are less secure. Run the following command :
Once you get the strength it will again ask you to change it . type NO.
It will then prompt for remove anonymous users, Disallow root login remotely, remove test database, reload test database & access it? enter Y for all the options.
Here we complete the MySQL installation securely.
4. MySQL Testing :
mysqladmin tool is used for testing the installation and also getting an information about it. It helps in running an administrative command. Use Following command.
This indicates that we have completed the installation successfully
As the demand for virtual private servers (VPS) continues to grow, businesses and individuals are faced with a crucial decision:…
Web hosting is a large industry, as many other factors help any web hosting provider to form a company. The…
Welcome to the complete guide to WordPress security best practices in 2024. As technology evolves rapidly, implementing strong security measures…
Hey, wanted to learn about web hosting? Or do you want to start a new website and need hosting? Questions…
In today's digital world, the threat of DDoS attacks has become increasingly prevalent. These types of attacks have the power…
View Comments