1、從mysql官網下載mysql-5.7.17的tar包
(mariadb和mysql只能有一個,因爲都是3306端口)
2、tar解包並查看內容
[root@mysql databases]# ls
mysql-5.7.17.tar
[root@mysql databases]# tar -xf mysql-5.7.17.tar
[root@mysql databases]# ls
mysql-5.7.17.tar
mysql-community-client-5.7.17-1.el7.x86_64.rpm
mysql-community-common-5.7.17-1.el7.x86_64.rpm
mysql-community-devel-5.7.17-1.el7.x86_64.rpm
mysql-community-embedded-5.7.17-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.17-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.17-1.el7.x86_64.rpm
mysql-community-libs-5.7.17-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.17-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.17-1.el7.x86_64.rpm
mysql-community-server-5.7.17-1.el7.x86_64.rpm
mysql-community-test-5.7.17-1.el7.x86_64.rpm
3、yum安裝rpm包
[root@mysql databases]# yum -y install mysql-community-*.rpm
##依賴包 perl-JSON.noarch.0.2.59-2.el7 自動安裝 \yum自動解決依賴包
4、查看mysqsl配置文件
[root@mysql databases]# vim /etc/my.cnf
4、啓動服務、查看進程
[root@mysql databases]# systemctl start mysqld
啓動服務
[root@mysql databases]# ss -nutplea | grep :3306
ss-nutpla查看進程 \grep :3306查找3306端口
5、初始密碼登陸(每一臺的初始密碼都不一樣)
[root@mysql ~]# grep password /var/log/mysqld.log
2018-11-06T01:33:10.324989Z 1 [Note] A temporary password is generated for root@localhost: ?9IS=DM?yQ-w
?9IS=DM?yQ-w //這個就是初始密碼
[root@mysql ~]# mysql -uroot -p?9IS=DM?yQ-w
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17
Copyright © 2000, 2016, 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>
5、修改密碼策略
修改全局變量要加global
mysql內的命令後要加 " ; "
初始密碼進入後先修改密碼,退出在用修改的密碼登陸後纔有權限
mysql>set global validate_password_policy=0;
//只驗證長度
Query OK, 0 rows affected (0.00 sec)
mysql>set global validate_password_length=6;
//修改密碼長度,默認值是8個字符
Query OK, 0 rows affected (0.00 sec)
mysql> alter user user() identified by "123456";
//修改登陸密碼
Query OK, 0 rows affected (0.00 sec)