Install MySQL database and centosmysql database on CentOS 7
Currently, software that does not use databases cannot be called software, but programs. On the Windows platform, MSSQLServer is deeply rooted in the hearts of the people. However, on the Linux platform, MySQL is replaced, so I have made some attempts to install MySQL on the Linux platform.
I. installation and configuration
1. download the required MySQL software package. We can go to the MySQL official website to find the download page. Because the Linux system I currently use is released in CentOS 7, then I can install it through the Yum Package Manager. First, download the MySQL Yum installation Source: slave.
2. on the download page of the Yum installation source, I can see that there are many versions of the installation source, but none of them are "For CentOS". Isn't it possible to install it? Of course not. CentOS is compiled by the source code released by Red Hat Enterprise Linux (RHEL for short) in accordance with open source code regulations. Therefore, the RHEL version installation source is also applicable to CentOS. So which version of RHEL is corresponding to CentOS 7 if there are so many "For RHEL" versions on the download page? In fact, it is not difficult to solve this problem. We only need to know the release history of CentOS to know which RHEL version it corresponds to. The release history of CentOS can be found in the CentOS entry of Wikipedia. Therefore, CentOS 7 corresponds to RHEL 7, so I can download this source package.
3. Start installation and installation.
sudo rpm -Uvh mysql-community-release-el7-5.noarch.rpm
4. Find the MySQL installation source list on the local machine.
yum repolist all | grep mysql
This operation may be slow. Please wait. After the search is completed, the following information is displayed on my machine:
It can be seen that three installation sources are "enabled", indicating that the software packages of the three installation sources will be installed. However, if for some reason we need to install the specified version of MySQL, we also need to modify the MySQL installation source configuration file/etc/yum. repos. d/mysql-community.repo. View the file to see the following content:
From lines 11th, 19, and 27, we can see that there is an "enable" option, which controls the MySQL version to be installed. If it is set to 0, this source is not used, otherwise, this source is used. Because the latest version is 5.6, I do not need to modify the installation source configuration file.
5. Install MySQL
sudo yum install mysql-community-server
6. Start the MySQL server
sudo service mysqld start
Check the MySQL server status:
sudo service mysqld status
Then we can see the highlighted green section, indicating that the server is already running.
To stop a MySQL Server:
sudo service mysqld stop
7. After starting, we need to configure security:
mysql_secure_installation
Then I will be prompted to perform a series of security settings:
(1) set the MySQL root User Password. Because the root password is blank when MySQL is first installed, when prompting us to enter the current root password, we should directly press the Enter key to indicate null. Enter the root password as prompted.
(2) then we are prompted whether to remove Anonymous users. This is YES of course.
(3) then, the system prompts whether the root user is allowed to log on remotely. According to the above prompt, the root user should log on only from the local device. I select YES to prevent the root user from logging on remotely, if you have such requirements, you can also allow the root user to log on remotely.
(4) Finally, the system prompts whether to remove the "test" database and reload the permission table.
Ii. Maintenance
1. install other optional MySQL Components
(1) first, we should find out which components are not installed. In the official MySQL quick installation guide, run the following command:
yum --disablerepo=\* --enablerepo='mysql*-community*' list available
Why does this command seem so uncomfortable? In fact, the prototype of this command is as follows:
yum [options] list available
What does "-- disablerepo = \ *" mean? Some people on the Internet say this tells Yum not to use all resources under the "\" directory. Which directory is this "\" directory? Ultimately all kinds of fruitless.
(2) After all available packages are displayed, run the Yum installation command.
(3) Update MySQL and its components:
sudo yum update mysql-server
References
- Http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/