In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to install CentOS 7 and configure MySQL 5.7.I hope you will get something after reading this article. Let's discuss it together.
CentOS 7 installation configuration MySQL 5.7
Overview
The previous article recorded the installation and configuration of MySQL 5.7 in the Windows system. Due to the need to install and deploy the big data environment, it is necessary to install and configure MySQL 5.7 centOS 7 environment in the CentOS 7 system. The installation configuration has also been recorded, so the installation and configuration is carried out here directly.
Yum source installation MySQL 5.7
Install MySQL 5.7
On CentOS 7 systems, the default source file does not contain MySQL, and executing the installation command directly using the yum source will prompt "there is no package mysql-community-server available." :
Therefore, you need to manually execute the following command to download the installation file of the source file:
1 # cd / home 2 # wget 'https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm'
Then execute the source file installation command:
1 # rpm-ivh mysql57-community-release-el7-11.noarch.rpm
Now you are ready to install MySQL by executing the following command:
1 # yum install-y mysql-community-server
Wait a moment and wait for the download and installation to complete:
Execute the following command to start the database and view the database status:
1 # systemctl start mysqld 2 # systemctl status mysqld
Configure MySQL 5.7
This version of the database will generate a random root user's password in the / var/log/mysqld.log file when it is installed, and view the file to get the password:
1 # cat / var/log/mysqld.log
Or use the following command:
1 # grep 'temporary password' / var/log/mysqld.log
Log in to the MySQL database using the following command:
1 # mysql-uroot-p
Enter the password you just found and log in to the database:
Use the following command to change the root user password:
1 > SET PASSWORD = PASSWORD ('password 123')
Remote access to the database is not open by default, so use the following command to configure:
1 > GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' password 123 WITH GRANT OPTION
Then enter quit, enter to log in to the database, and use the command to open the configuration file of the database:
1 # vim / etc/my.cnf
Set the database character set to utf8mb4, and set sql_mode to support group by statements. The complete configuration file is 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:
Set to utf8mb4: first, because utf8 encoding only supports 3 bytes of data, while the mobile emoji data is 4 bytes of characters, inserting facial expression data directly into the utf-8-encoded database will report an exception; second, read an article by a great god that utf8 in MySQL is not a real utf8, so use utf8mb4.
After the configuration is complete, restart the database service by executing the following command:
1 # systemctl restart mysqld
Using the modified password, log in to the database and execute the following command to view the character set settings:
1 # SHOW VARIABLES LIKE 'character%'
Set the database service to boot by executing the following command:
1 # systemctl enable mysqld
Compressed package installation MySQL 5.7
If the server cannot be connected to the network and cannot be installed using a yum source, you can use a computer that can be connected to the Internet to download the compressed package on the official website and install it on a different server.
First of all, go to the official website: https://www.mysql.com/ to download the relevant installation package:
Remotely connect to the / usr directory on the server to create a mysql57:
1 # cd / usr 2 # mkdir mysql57
Use Xftp to upload the compressed package to the mysql57 directory on the server:
Since mariadb is installed by default on the CentOS 7 system, view and uninstall mariadb using the following command:
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
Start the MySQL service using the following command and check the running status of the service:
1 # systemctl start mysqld 2 # systemctl status mysqld
MySQL 5.7Database installation is complete.
Configure MySQL 5.7
Check the log file to get the password:
1 # grep 'temporary password' / var/log/mysqld.log
Log in to the MySQL database using the following command:
1 # mysql-uroot-p
Enter the password you just found and log in to the database:
Use the following command to change the root user password:
1 > SET PASSWORD = PASSWORD ('*')
Remote access to the database is not open by default, so use the following command to configure:
1 > GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' * 'WITH GRANT OPTION
The asterisk is the password of the root user (red coverage area below):
Then enter quit, enter to log in to the database, and use the command to open the configuration file of the database:
1 # vim / etc/my.cnf
Set the database character set to utf8mb4, and set sql_mode to support group by statements. The complete configuration file is 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:
Set to utf8mb4: first, because utf8 encoding only supports 3 bytes of data, while the mobile emoji data is 4 bytes of characters, inserting facial expression data directly into the utf-8-encoded database will report an exception; second, read an article by a great god that utf8 in MySQL is not a real utf8, so use utf8mb4.
After the configuration is complete, restart the database service by executing the following command:
1 # systemctl restart mysqld
Using the modified password, log in to the database and execute the following command to view the character set settings:
1 # SHOW VARIABLES LIKE 'character%'
Set the database service to boot by executing the following command:
1 # systemctl enable mysqld
Because two different installation methods are recorded, the configuration is also recorded twice. I just hope that friends who see different installation methods do not need to go back to the configuration.
After reading this article, I believe you have a certain understanding of "how to install and configure CentOS 7". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.