Centos7.5 yum 安装mysql5.7

Centos7.5通过yum安装mysql5.7

注:安装的是mysql5.7并不是mariadb-server

基础环境准备,不做过多描述之前文档中都详细解释过。

[root@localhost ~]# hostname --all-ip
192.168.200.101 
[root@localhost ~]# firewall-cmd --stat
not running
[root@localhost ~]# getenforce
Disabled
[root@localhost ~]# iptables -nL
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
[root@localhost ~]# systemctl status iptables
● iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
[root@localhost ~]# ping -c 4 csdn.net
PING csdn.net (47.95.164.112) 56(84) bytes of data.
64 bytes from 47.95.164.112 (47.95.164.112): icmp_seq=1 ttl=128 time=6.91 ms
64 bytes from 47.95.164.112 (47.95.164.112): icmp_seq=2 ttl=128 time=5.52 ms
64 bytes from 47.95.164.112 (47.95.164.112): icmp_seq=3 ttl=128 time=7.51 ms
64 bytes from 47.95.164.112 (47.95.164.112): icmp_seq=4 ttl=128 time=5.27 ms

--- csdn.net ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 5.277/6.308/7.511/0.935 ms

配置mysql5.7的yum源

[root@localhost ~]# yum install -y http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
[root@localhost ~]# ll /etc/yum.repos.d/					//确认mysql的repo文件
总用量 24
drwxr-xr-x. 2 root root  187 9月   3 15:45 bak
-rw-r--r--. 1 root root 2523 9月   3 15:45 Centos-7.repo
-rw-r--r--. 1 root root  951 10月  3 2017 epel.repo
-rw-r--r--. 1 root root 1050 10月  3 2017 epel-testing.repo
-rw-r--r--. 1 root root 1245 9月   3 15:53 mslinux.repo
-rw-r--r--  1 root root 1627 4月   5 2017 mysql-community.repo
-rw-r--r--  1 root root 1663 4月   5 2017 mysql-community-source.repo
[root@localhost ~]#yum -y install mysql-community-server
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 四 2019-09-19 16:37:57 CST; 10s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 16398 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 16324 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 16401 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─16401 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

9月 19 16:37:54 localhost.localdomain systemd[1]: Starting MySQL Server...
9月 19 16:37:57 localhost.localdomain systemd[1]: Started MySQL Server.
[root@localhost ~]# systemctl enable mysqld
[root@localhost ~]# grep 'password' /var/log/mysqld.log 					//查看mysql密码
2019-09-19T08:37:54.700678Z 1 [Note] A temporary password is generated for root@localhost: gYD.1l>Gr47X
注:mysql5.7开始默认root密码在mysql的log中
[root@localhost ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.27

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)

mysql> alter user 'root'@'localhost' identified by '123123';
Query OK, 0 rows affected (0.00 sec)

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)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye


注:
validate_password_policy 这个参数用于控制validate_password的验证策略 0-->low  1-->MEDIUM  2-->strong。

validate_password_length密码长度的最小值(这个值最小要是4)。

validate_password_number_count 密码中数字的最小个数。

validate_password_mixed_case_count大小写的最小个数。

validate_password_special_char_count 特殊字符的最小个数。

validate_password_dictionary_file 字典文件


 修改方法
 set global  xxx=num

mysql5.7部署完成,加油方法总比问题多!!!

你可能感兴趣的:(mysql)