mysql5.7安裝
1.1 進入本機源文件目錄/usr/local/src
# cd /usr/local/src/
1.2 wget mysql的rpm包
# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
1.3 運行rpm命令預編譯
# rpm -ivh mysql57-community-release-el7-11.noarch.rpm
warning: mysql57-community-release-el7-11.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql57-community-release-el7-11 ################################# [100%]
[root@iZ23hdndo4vZ src]#
1.4 yum方式安裝mysql-server
# yum install -y mysql-server
1.5 啓動停止mysql服務命令
# systemctl start mysqld
# systemctl stop mysqld
1.6 查找初始密碼
# cat /var/log/mysqld.log
2018-09-19T06:43:48.776000Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-09-19T06:43:50.543804Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-09-19T06:43:50.754544Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-09-19T06:43:50.821659Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 5e3cf68a-bbd7-11e8-86d0-00163e09c8b0.
2018-09-19T06:43:50.824047Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-09-19T06:43:50.824508Z 1 [Note] A temporary password is generated for root@localhost: /oCbd<c+4exw
初始密碼爲:/oCbd<c+4exw
1.7 進入mysql服務修改初始化的密碼
# mysql -u root -p
Enter password:
設置修改的密碼不做任務驗證
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
設置新的密碼
mysql> alter user 'root'@'localhost' identified by '新的密碼';
1.8 新建數據庫,並新建用戶,開通外網訪問權限
創建數據庫ds9
mysql> create database ds9;
創建兩個用戶
mysql> create user 'dianshi9'@'localhost' identified by '密碼';
Query OK, 0 rows affected (0.00 sec)
mysql> create user 'ds9_select'@'%' identified by '密碼';
Query OK, 0 rows affected (0.00 sec)
爲數據庫分配權限
給用戶dianshi9分配ds9數據庫的內網操作的所有權限
mysql> grant all privileges on ds9.* to 'dianshi9'@'localhost' identified by '密碼';
Query OK, 0 rows affected, 1 warning (0.00 sec)
給用戶ds9_select分配所有網絡的select,insert,update操作權限
mysql> grant select,update,insert on ds9.* to 'ds9_select'@'%' identified by '密碼';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
完成