Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and uninstall MySQL in CentOS7.0

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to install and uninstall MySQL in CentOS7.0. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

MySQL installation configuration YUM source

Download the YUM source rpm installation package from the MySQL official website

Image.png

# download mysql source installation package shell > wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm# install MySQL source shell > yum localinstall mysql57-community-release-el7-11.noarch.rpm# check whether 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 vim / etc/yum.repos.d/mysql-community.repo source to change the version of mysql installed by default. For example, to install version 8.0, change the enabled=1 of the 5.7source to enabled=0. Then change the enabled=0 of the 8.0 source to enabled=1. Caching_sha2_password authentication mechanism is used by default if version 8.0 is not used for the time being. After adding a remote account, the access method may be different. Anyway, I did not connect successfully, so I switched back to 5.7. The effect of the modification is as follows:

Install MySQLshell > yum install mysql-community-server to start the MySQL service shell > systemctl start mysqld to view the startup status of MySQL shell > systemctl status mysqld

Boot shell > systemctl enable mysqldshell > systemctl daemon-reload to modify the root local login 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.log

Shell > 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:

Policy check rules

0 or LOW Length

1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters

2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file

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

Select one of 0 (LOW), 1 (MEDIUM), 2 (STRONG), and choose 2 requires 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 add Telnet 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 'guest'@'%' IDENTIFIED BY' Guest 1234 encoding; the default configuration code is utf8

Modify the / etc/my.cnf configuration file and add the encoding configuration under [mysqld], as follows:

Restart the mysql service and view the database default code as follows:

Default profile path:

Configuration file: / etc/my.cnf

Log file: / var/log/mysqld.log

Service startup script: / usr/lib/systemd/system/mysqld.service

Socket file: / var/run/mysqld/mysqld.pid

Mysql completely uninstall delete Mysqlshell > yum remove mysql mysql-server mysql-libs mysql-server# will find related things delete (rm-rf / var/lib/mysql) shell > find /-name mysql # query yum remove shell > rpm-qa | grep mysqlshell > rm / etc/my.cnf

Check to see if mysql software is still available:

Rpm-qa | grep mysql

If it exists, just continue to delete it.

Mysql installed in rpm mode

Check to see if the mysql installed in the rpm package is on the system:

[root@localhost opt] # rpm-qa | grep-I mysqlMySQL-server-5.6.17-1.el6.i686MySQL-client-5.6.17-1.el6.i686

Uninstall mysql

[root@localhost local] # rpm-e MySQL-server-5.6.17-1.el6.i686 [root@localhost local] # rpm-e MySQL-client-5.6.17-1.el6.i686

Delete mysql service

[root@localhost local] # chkconfig-- list | grep-I mysql [root@localhost local] # chkconfig-- del mysql

Delete scattered mysql folders

[root@localhost local] # whereis mysql or find /-name mysql

Mysql: / usr/lib/mysql / usr/share/mysql

Clear all directories and files related to mysql

Rm-rf / usr/lib/mysql

Rm-rf / usr/share/mysql

Rm-rf / usr/my.cnf

On how to install and uninstall MySQL in CentOS7.0 is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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: 296

*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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report