資料庫版本標準化 1.確認Supported Platforms https://www.mysql.com/support/ 2.確認安裝版本 推薦:5.7.22 ,8.0.20以後的雙數GA版本 3.獲取MySQL軟體包 https://downloads.mysql.com/archives/ ...
資料庫版本標準化 1.確認Supported Platforms https://www.mysql.com/support/ 2.確認安裝版本 推薦:5.7.22 ,8.0.20以後的雙數GA版本 3.獲取MySQL軟體包 https://downloads.mysql.com/archives/community/ 4.MD5驗證 安裝與部署 官方安裝文檔:https://dev.mysql.com/doc/refman/8.0/en/binary-installation.html 1. 部署前準備 1.解壓 tar -xf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz 3. 環境清理 # yum remove -y mariadb-libs # yum install libaio 4. 創建組 # groupadd mysql 5. 創建用戶 # useradd -r -g mysql -s /bin/false mysql 5. 創建目錄 # mkdir -p /data/3306/data/ 6. 複製以及創建軟連接 # cd /usr/local/ # cp /opt/mysql-8.0.24-linux-glibc2.12-x86_64 ./ -rp # ln -s mysql-8.0.24-linux-glibc2.12-x86_64/ mysql 2.部署 1.在mysql下創建目錄 [root@localhost local]# cd mysql [root@localhost mysql]# mkdir mysql-files 2. 授權 [root@localhost mysql]# chown mysql.mysql mysql-files [root@localhost mysql]# chmod 750 mysql-files/ 3. 初始化安裝--預設配置 [root@localhost mysql]# ./bin/mysqld --initialize --user=mysql 2022-05-15T09:16:50.594508Z 0 [System] [MY-013169] [Server] /usr/local/mysql-8.0.24-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.24) initializing of server in progress as process 2637 2022-05-15T09:16:50.602884Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2022-05-15T09:16:50.995550Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2022-05-15T09:16:51.624080Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: tFsl6zx2Cp<l ##預設密碼 tFsl6zx2Cp<l ##[root@localhost mysql]# ./bin/mysqld --initialize-insercute --user=mysql 空密碼 4. 創建RSA文件和SSL文件確保加密功能 ##銀行可能會有,互聯網基本不會設置 [root@localhost mysql]# bin/mysql_ssl_rsa_setup 5. 啟動mysql [root@localhost mysql]# ./bin/mysqld_safe --user mysql & 6. 客戶端方式登陸mysql [root@localhost mysql]# mysql -uroot -p'tFsl6zx2Cp<l' -hlocalhost -P3306 7. 修改密碼 mysql> ALTER USER USER() IDENTIFIED BY 'Chiyu45D'; 8. 介面方式登陸 [root@localhost mysql]# ./bin/mysql -uroot -pChiyu45D -S /tmp/mysql.sock 9. 創建用戶並賦權 mysql> create user yuyang@localhost identified by 'Chiyu45D'; Query OK, 0 rows affected (0.01 sec) mysql> grant all on *.* to yuyang@localhost with grant option; Query OK, 0 rows affected (0.00 sec) 10. 將mysql命令加入到系統命令 [root@localhost mysql]# vim /etc/profile 在文檔最下方加入如下語句: export PATH=/usr/local/mysql/bin:$PATH [root@localhost mysql]# source /etc/profile 註:系統安裝一般用於測試環境,生產環境一般會自定義安裝 系統安裝會有一些缺點,例如 1、sock文件在/tmp目錄下 2、日誌文件在/var/log目錄下 3、配置文件在/etc/my.cnf目錄下