In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you how to install MySQL5.7 under CentOS7 64-bit, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Installation environment: CentOS7 64-bit MINI version, install MySQL5.7
1. Configure the YUM source
Download the YUM source rpm installation package: http://dev.mysql.com/downloads/repo/yum/ from the MySQL official website
# download mysql source installation package shell > wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm# install MySQL source shell > yum localinstall mysql57-community-release-el7-8.noarch.rpm
Check whether the MySQL source is installed successfully
Shell > yum repolist enabled | grep "mysql.*-community.*"
Seeing the figure above indicates that the installation is successful.
You can modify the yum source to change the version of mysql installed by default. For example, if you want to install version 5.7, you can change the enabled=0 of the 5.7 source to enabled=1. The effect of the modification is as follows:
Vim / etc/yum.repos.d/mysql-community.repo
2. Install MySQL
Shell > yum install mysql-community-server
3. Start the MySQL service
Shell > systemctl start mysqld
Check the startup status of MySQL
4. Boot and start
Shell > systemctl enable mysqldshell > systemctl daemon-reload
5. Modify the local login password of root. It is possible that the default password of root is empty.
1. If the default password is empty, enter directly to log in.
If you have a password, after the mysql installation is complete, a default password is generated for root in the / var/log/mysqld.log file. Find the root default password in the following ways, and then log in to mysql to modify it:
Shell > grep 'temporary password' / var/log/mysqld.logshell > mysql-uroot-pmysql > ALTER USER' root'@'localhost' IDENTIFIED BY 'MyNewPass4 passport; or mysql > set password for' root'@'localhost'=password ('MyNewPass4passport')
Note: mysql5.7 installs the password Security check plug-in (validate_password) by default. The default password check policy requires that passwords must contain uppercase and lowercase letters, numbers and special symbols, and must be no less than 8 digits in length. Otherwise, ERROR 1819 (HY000): Your password does not satisfy the current policy requirements error will be prompted, as shown in the following figure:
You can view information about password policies through the msyql environment variable:
Mysql > show variables like'% password%'
Validate_password_policy: password policy. Default is MEDIUM policy.
Validate_password_dictionary_file: password policy file, which is required only if the policy is STRONG
Validate_password_length: minimum password length
Validate_password_mixed_case_count: length of uppercase and lowercase characters, at least 1
Validate_password_number_count: at least 1 number
Validate_password_special_char_count: at least 1 special character
The above parameters are the password checking rules of the default policy MEDIUM.
There are several password policies:
MySQL official website password policy details: http://dev.mysql.com/doc/refman/5.7/en/validate-password-options-variables.html#sysvar_validate_password_policy
Modify password policy
Add validate_password_policy configuration in / etc/my.cnf file to specify password policy
# choose one of 0 (LOW), 1 (MEDIUM), 2 (STRONG), and choose 2 requires providing a password dictionary file validate_password_policy=0
If you do not need a password policy, add the following configuration to the my.cnf file to disable it:
Validate_password = off
Restart the mysql service for the configuration to take effect:
Systemctl restart mysqld
6. Add a remote login user
By default, only root accounts are allowed to log in locally. If you want to connect to mysql on other machines, you must modify root to allow remote connections, or add an account that allows remote connections. For security reasons, I add a new account:
Mysql > GRANT ALL PRIVILEGES ON *. * TO 'yangxin'@'%' IDENTIFIED BY' Yangxin 0917 years' WITH GRANT OPTION
7. Configure the default encoding as utf8
Modify the / etc/my.cnf configuration file and add the encoding configuration under [mysqld], as follows:
[mysqld] character_set_server=utf8init_connect='SET NAMES utf8'
Restart the mysql service and view the database default code as follows:
Default profile path:
Configuration file: / etc/my.cnf
Log file: / var/log//var/log/mysqld.log
Service startup script: / usr/lib/systemd/system/mysqld.service
Socket file: / var/run/mysqld/mysqld.pid
Centos7 Uninstall mysql
View current installation status
Rpm-qa | grep-I mysql
Yum remove mysql
Rpm-e mysql-community-release-el7-5.noarch
If prompted to rely on errors
Then execute
Rpm-ev-nodeps mysql-community-libs-5.6.43-2.el7.x86_64
Delete it according to this method
Then find the directory of the previous version of mysql, and delete the files and libraries of the old version of mysql. I did not delete the old library, but made an upgrade and installation directly.
Find /-name mysql
Delete the corresponding mysql directory
Rm-rf / var/lib/mysql
Note: / etc/my.cnf will not be deleted after uninstallation and needs to be deleted manually
Rm-rf / etc/my.cnf
Sometimes my.cnf may not be under / etc. You can use the command to find it.
Find /-name my.cnf
Check again to see if the machine has mysql installed
Rpm-qa | grep-I mysql
I did not delete the original configuration file, database, directly installed 5.7, the original data inventory, but the database is not available, I used two commands to solve.
Set @ @ global.show_compatibility_56=ON
The original database can be used normally.
The above is all the contents of the article "how to install MySQL5.7 under CentOS7 64-bit". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.