Overview
previously recorded configuration of MySQL 5.7 installed on Windows systems (previously connected: https://www.cnblogs.com/Dcl-Snow/p/10513925.html ), due to the need to install and deploy big data environment, now in CentOS 7 system installation configuration MySQL 5.7, CentOS 7 environmental installation configuration had also been recorded (previously connected: https://www.cnblogs.com/Dcl-Snow/p/10811659.html ), where it is directly mounted configuration.
yum install MySQL 5.7 source
installed MySQL 5.7
on CentOS 7 system, the system default source file does not contain MySQL directly using yum source to perform the installation command prompt "is not available Package mysql-community-server.":it is necessary to manually execute the following commands, download the source files of the installation files:
1 # cd /home 2 # wget 'https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm'
Source file and then perform the installation command:
1 # rpm -ivh mysql57-community-release-el7-11.noarch.rpm
You can now install MySQL, and execute the following command:
1 # yum install -y mysql-community-server
Wait until the installation is complete download: Run the following command to start the database and view the database state:
1 # systemctl start mysqld 2 # systemctl status mysqld
Configure MySQL 5.7
The version of the database will be, will generate a random root user in /var/log/mysqld.log file when you install a password to view the file to obtain the password:
1 # cat /var/log/mysqld.log
Or using the following command:
1 # grep 'temporary password' /var/log/mysqld.log
Login MySQL database using the following command:
1 # mysql -uroot -p
Just enter the password found in password, you can log database: Use the following command to change the root password:
1 > SET PASSWORD = PASSWORD('Password@123!');
The default remote access to the database is not open, use the following command to configure:
1 > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Password@123!' WITH GRANT OPTION;
Then enter quit, quit Enter the database login, use the command to open the configuration file for the database:
1 # vim /etc/my.cnf
Set the database character set is utf8mb4, and set sql_mode support group by statement, complete configuration file as follows:
1 [mysqld] 2 datadir=/var/lib/mysql 3 socket=/var/lib/mysql/mysql.sock 4 symbolic-links=0 5 log-error=/var/log/mysqld.log 6 pid-file=/var/run/mysqld/mysqld.pid 7 character-set-server = utf8mb4 8 collation-server = utf8mb4_unicode_ci 9 sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 10 11 [mysql] 12 default-character-set = utf8mb4 13 14 [client] 15 default-character-set = utf8mb4 16
Note:
here is set to utf8mb4: first, because the utf8 encoding supports only 3 bytes of data, and the moving end of the expression data is four-byte characters, insert expression data directly to utf8 encoded database, will be reported abnormal; second is to read a big article mentioned God, MySQL is not a real utf8 utf8, so use utf8mb4.
After the configuration, run the following commands to restart the database service:
1 # systemctl restart mysqld
Using the modified password, login to the database, execute the following command to view the character set:
1 # SHOW VARIABLES LIKE 'character%';
Run the following commands to set the database service startup:
1 # systemctl enable mysqld
Archive install MySQL 5.7
If the server can not be networked, you can not use yum source installation, you can use network-enabled computer, go to the official website to download the compressed package is installed, the following exchange servers to compress package installation.
First, go to the official website: https://www.mysql.com/ download the installation package: a remote connection to / usr directory on the server to create mysql57:
1 # cd /usr 2 # mkdir mysql57
Use Xftp uploaded to the archive directory on the server mysql57: Because CentOS 7 system is installed by default mariadb, use the following command to view and uninstall mariadb:
1 # rpm -qa | grep mariadb 2 # rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
Then use the rpm command to install:
1 # rpm -ivh * .rpm
Use the following command to start the MySQL service, and view the status of services running:
1 # systemctl start mysqld 2 # systemctl status mysqld
MySQL 5.7 database installation is complete.
Configure MySQL 5.7
to view the log file for the password:
1 # grep 'temporary password' /var/log/mysqld.log
Login MySQL database using the following command:
1 # mysql -uroot -p
Just enter the password found in password, you can log database: Use the following command to change the root password:
1 > SET PASSWORD = PASSWORD('******');
The default remote access to the database is not open, use the following command to configure:
1 > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '******' WITH GRANT OPTION;
An asterisk (covering areas below red) for the root user's password: and enter quit, quit Enter the database login, use the command to open the configuration file for the database:
1 # vim /etc/my.cnf
Set the database character set is utf8mb4, and set sql_mode support group by statement, complete configuration file as follows:
1 [mysqld] 2 character-set-server = utf8mb4 3 collation-server = utf8mb4_unicode_ci 4 sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 5 6 [mysql] 7 default-character-set = utf8mb4 8 9 [client] 10 default-character-set = utf8mb4 11
Note:
here is set to utf8mb4: first, because the utf8 encoding supports only 3 bytes of data, and the moving end of the expression data is four-byte characters, insert expression data directly to utf8 encoded database, will be reported abnormal; second is to read a big article mentioned God, MySQL is not a real utf8 utf8, so use utf8mb4.
After the configuration, run the following commands to restart the database service:
1 # systemctl restart mysqld
Using the modified password, login to the database, execute the following command to view the character set:
1 # SHOW VARIABLES LIKE 'character%';
Run the following commands to set the database service startup:
1 # systemctl enable mysqld
Because the record two different ways of installation, the configuration also recorded twice, just want to see people from different installation methods do not need to go back and turn configuration, thus CentOS 7 installation configuration MySQL 5.7 recording is complete.