Recently do a project, need to use CentOS to do data server, with MySQL database, you need to install MySQL database, did not contact with CentOS, so what do not understand, from the internet also looked up a lot of information, are not the best way. Finally unifies the MySQL official information and the Netizen's data, finally uses the RPM method installs, and summarizes to other people to consult.
First open the MySQL pipe network, find "Yum repository" open the page or directly open the following link
http://dev.mysql.com/downloads/repo/yum/
, find what you need, click Download, download the rpm file, download it in CentOS. House can be installed with the software manager, or it can be installed on its own command line
sudo rpm-uvh ' filename '
Complete the installation.
Input
You can view all of the MySQL corresponding RPM packages, if the previous version of the installation, you need to set up the appropriate settings, open
/etc/yum.repos.d/mysql-community.repo
file, set the corresponding version of the Enabled property, 1 is enabled, 0 is disabled, and if you install the current latest version, you do not need to make any settings.
Enter the following command to start the installation of MySQL
sudo yum install Mysql-community-server
Wait for the installation to complete, enter the following command to start the MySQL service
sudo service mysqld start
House can view the status of MySQL service when it is started
sudo service mysqld status
If the 5.7 version is installed, the following actions occur when the service starts because the data directory is empty:
- Initializing the server
- Generate an SSL certificate and key file in the data directory
- Install and enable the Validate_password plugin
- The Superuser account ' root ' @ ' localhost ' is created, the superuser password is set and stored in the error log file, if it needs to be displayed, execute the following command
sudo grep ' temporary password '/var/log/mysqld.log
A random password is generated and is entered at the command line
Plus just the random password, log in to MySQL.
After logging on to the server with this password, you must change the password immediately, or you will be reported as follows (local reference http://www.cnblogs.com/ivictor/p/5142809.html):
Mysql> Select User (); ERROR 1820 (HY000): Must reset your password using ALTER USER statement before executing this statement.
If you just change to a simple password, the following error will be reported:
mysql> ALTER User User () identified by ' 12345678 '; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
This is actually related to the value of Validate_password_policy.
The validate_password_policy has the following values:
Policy |
Tests performed |
0 OrLOW |
Length |
1 OrMEDIUM |
Length; Numeric, lowercase/uppercase, and special characters |
2 OrSTRONG |
Length; Numeric, lowercase/uppercase, and special characters; Dictionary file |
The default is 1, which is medium, so the password you just started must match the length and must contain numbers, lowercase or uppercase letters, special characters.
Sometimes, just for your own testing, don't want to set the password so complicated, for example, I just want to set the root password is 123456.
Two global parameters must be modified:
First, modify the value of the Validate_password_policy parameter
mysql> set global validate_password_policy=0; Query OK, 0 rows Affected (0.00 sec)
Changes can be made to your own password after the change.
After the setup is complete, you need to set the remote access permission for MySQL, there are two places to set up, one is open to external IP address, one is port open.
The most common setting is to set up MySQL authorization with the following command
GRANT all privileges on * * to ' root ' @ '% ' identified by ' Youpassword ' with GRANT OPTION;
If you want to set an authorization for an IP address, you need to change the% to your IP address, Setup complete, re-authorize the table
FLUSH privileges;
Then exit to quit MySQL and restart MySQL
Service mysqld Restart
Set 3306 ports open via Firewall-cmd in Centos7
Firewall-cmd--zone=public--add-port=3306/tcp--permanent
Setup complete, Reload firewall
Firewall-cmd--reload
To see if Port 3306 is set successfully by command
Firewall-cmd--list-all-zones
At this point, MySQL installation and configuration is complete in CENTOS7
Centos7 installing MySQL summary with rpm