Home>Article>Operation and Maintenance> How to install MySQL through yum in CentOS7
How to install MySQL in CentOS7 through yum?
##1. Download and install MySQL’s official Yum Repository
[root@localhost ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpmUse the above command to directly download Yum for installation. Repository, about 25KB, can be installed directly with yum.
[root@localhost ~]# yum -y install mysql57-community-release-el7-10.noarch.rpmThen start installing the MySQL server.
[root@localhost ~]# yum -y install mysql-community-serverThis step may take some time. After the installation is completed, the previous mariadb will be overwritten. Now the MySQL installation is complete, and then there are some settings for MySQL.
2 MySQL database settings
First start MySQL[root@localhost ~]# systemctl start mysqld.serviceView the MySQL running status, the running status is as shown in the figure:
[root@localhost ~]# systemctl status mysqld.serviceAt this time, MySQL has started to run normally, but if you want to enter MySQL, you must first find out the password of the root user. You can find the password in the log file through the following command:
[root@localhost ~]# grep "password" /var/log/mysqld.logThe following command enters the database:
[root@localhost ~]# mysql -uroot -pEnter the initial password. You cannot do anything at this time, because MySQL must change the password by default before operating the database:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';There is a problem here. When setting a new password, if the setting is too simple, an error will be reported: The reason is because MySQL has password setting specifications, which are specifically related to the value of validate_password_policy: The complete initial password rules of MySQL can be viewed through the following command:
mysql> SHOW VARIABLES LIKE 'validate_password%'; +--------------------------------------+-------+ | Variable_name | Value | +--------------------------------------+-------+ | validate_password_check_user_name | OFF | | validate_password_dictionary_file | | | validate_password_length | 4 | | validate_password_mixed_case_count | 1 | | validate_password_number_count | 1 | | validate_password_policy | LOW | | validate_password_special_char_count | 1 | +--------------------------------------+-------+ 7 rows in set (0.01 sec)The length of the password is determined by validate_password_length, and the calculation formula of validate_password_length is:
validate_password_length = validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)我的是已经修改过的,初始情况下第一个的值是ON,validate_password_length是8。可以通过如下命令修改:
mysql> set global validate_password_policy=0; mysql> set global validate_password_length=1;After setting, it will be the values I found above. At this time, the password can be set very simply, such as 1234. The password setting for this database is completed. But there is another problem at this time, that is, because the Yum Repository is installed, every yum operation will be automatically updated in the future, and this needs to be uninstalled:
[root@localhost ~]# yum -y remove mysql57-community-release-el7-10.noarchRelated references: At this time, it is really completed.
The above is the detailed content of How to install MySQL through yum in CentOS7. For more information, please follow other related articles on the PHP Chinese website!