為什麼不用 mysql80 ?
別不信邪,因為很多實驗數據結果顯示,在 < 300 threads 時
效能 mysql5.6 > mysql5.7 > mysql8
不是版本愈高就愈好,而是要選擇適合你的。小型網站或使用者不多的不一定要拿牛刀,MySQL 在Oracle 接管後進步很緩慢,差別真的不大。
但本安裝步驟不分版本,稍改一下版本字元即可通用
如果你只想安裝 mysql,不 care 版本,
1. 安裝前看一下版本
# yum info mysql-community-server
Available Packages
Name : mysql-community-server
Arch : x86_64
Version : 5.6.48
Release : 2.el7
....
....
2. 安裝
# yum install mysql-community-server
安裝指定版本,這裡是 mysql 5.7
0.檢查 repo source 是否已有 mysql57
# yum repolist enabled | grep "mysql.*-community.*"
!mysql-connectors-community/x86_64 MySQL Connectors Community 153
!mysql-tools-community/x86_64 MySQL Tools Community 110
!mysql56-community/x86_64 MySQL 5.6 Community Server 530
不符合我們版本
毋須指定 release no, architecture independ (例 mysql57-community-release-el7-xx.rpm)
# wget https://repo.mysql.com/mysql57-community-release-el7.noarch.rpm
2. 安裝 (# 提示字 就是 root 身分,你應該知道的)
安裝 mysql5.7 安裝源(repo source)
# yum localinstall mysql57-community-release-el7.rpm
3. 檢查資源狀態
# yum repolist all | grep mysql5
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - disabled
mysql56-community/x86_64 MySQL 5.6 Community Server enabled: 530
mysql56-community-source MySQL 5.6 Community Server - disabled
mysql57-community-dmr/x86_64 MySQL 5.7 Community Server D disabled
mysql57-community-dmr-source MySQL 5.7 Community Server D disabled
enable 的還是 mysql56, 意指目前還是預設指向 mysql56
4. 切換 mysql 安裝來源
關56
# yum-config-manager --disable mysql56-community
開57
# yum-config-manager --enable mysql57-community-dmr
切換完你可以再檢查一下 (可略)
# yum repolist all | grep mysql5 是否已切換了
或第一步驟指令再檢查一下 (可略)
# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community 153
mysql-tools-community/x86_64 MySQL Tools Community 110
mysql57-community-dmr/x86_64 MySQL 5.7 Community Server Development 424
5. 安裝
# yum install mysql-community-server -y
6. 啟動服務 & 檢查服務狀態
# systemctl start mysqld
# systemctl status mysqld
Active: active (running)
6-1. root 的預設密碼在哪裡?
根據官網給的資訊,預設密碼在 /var/log/mysqld.log ,用以下指令
# sudo grep 'temporary password' /var/log/mysqld.log
# sudo grep 'temporary password' /var/log/mysqld.log
2020-05-28T09:47:04.213709Z 1 [Note] A temporary password is generated for root@localhost: #c3/f5KDwtko
登入試試
# mysql -uroot -p
# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.30
Copyright (c) 2000, 2020, 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>
成功!!!
6-2. 變更密碼
在 mysql> 下變更密碼
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('我的新密碼');
Query OK, 0 rows affected, 1 warning (0.00 sec)
下次登入即可使用該密碼
6-3. 開機自動執行
# systemctl enabled mysqld
安裝步驟到此全部完成!!!
7. 追加,安裝附屬套件!!!
安裝 Shared compat libraries for MySQL ,我們程式 compile 所需 lib 及 python mysql connector 需要。
# yum install mysql-community-libs-compat
註:libmysqlclient.so.18、libmysqlclient.so
沒有留言:
張貼留言