centos7安裝mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
本來不準備寫這個的,網上太多了,但是情況各有區別,我沒有發現一篇我能照著安裝成功。經過一番折騰,終於安裝完了。
一、首先到官網下載吧:
https://dev.mysql.com/downloads/file/?id=469456
二、解壓:
#tar -xvf mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
解壓後有如下rpm:
[[email protected] mysql_rpm]# ls -l
總用量 1141908
-rw-r--r-- 1 root root 584652800 5月 13 01:02 mysql-5.7.18-1.el7.x86_64.rpm-bundle.tar
-rw-r--r-- 1 7155 31415 25079412 3月 20 17:40 mysql-community-client-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 277784 3月 20 17:40 mysql-community-common-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 3777808 3月 20 17:40 mysql-community-devel-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 45493312 3月 20 17:40 mysql-community-embedded-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 23924496 3月 20 17:40 mysql-community-embedded-compat-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 126060264 3月 20 17:40 mysql-community-embedded-devel-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 2237888 3月 20 17:40 mysql-community-libs-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 2113196 3月 20 17:40 mysql-community-libs-compat-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 54661812 3月 20 17:40 mysql-community-minimal-debuginfo-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 169622200 3月 20 17:41 mysql-community-server-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 14501488 3月 20 17:41 mysql-community-server-minimal-5.7.18-1.el7.x86_64.rpm
-rw-r--r-- 1 7155 31415 116887988 3月 20 17:41 mysql-community-test-5.7.18-1.el7.x86_64.rpm
三、一個rpm一個rpm的來安裝吧
這裡要注意安裝順序,但是其實不用記順序。
比如我先安裝server吧:(如果沒有安裝common和client就會報錯)
#rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-server-5.7.18-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 金鑰 ID 5072e1f5: NOKEY
錯誤:依賴檢測失敗:
mysql-community-client(x86-64) >= 5.7.9 被 mysql-community-server-5.7.18-1.el7.x86_64 需要
mysql-community-common(x86-64) = 5.7.18-1.el7 被 mysql-community-server-5.7.18-1.el7.x86_64 需要
有人說可以取消依賴:#rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm --nodeps,但是個人不建議這麼做,安裝好後可能也會有問題,rpm都有了,依賴檢測失敗你就裝上依賴就是了。
3.1好吧,那就先安裝common吧
# rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-common-5.7.18-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 金鑰 ID 5072e1f5: NOKEY
準備中... ################################# [100%]
file /usr/share/mysql/czech/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64conflicts with file
file /usr/share/mysql/danish/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
... ...
file /usr/share/mysql/estonian/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
file /usr/share/mysql/french/errmsg.sys from install of mysql-community-common-5.7.18-1.el7.x86_64 conflicts with file from package mariadb-libs-1:5.5.44-2.el7.centos.x86_64
... ...
來自mysql-ccommunity-common-5.7.18-1.el7.x86_的檔案和mariadb-libs-1:5.5.44-2.el7.centos.x86_64的檔案衝突?什麼意思?查了下:
出現以上安裝錯誤列表的原因是:系統已經安裝了其他版本的mysql-libs包和mysql資料庫檔案導致不相容 解決:# yum remove mysql-libs ------------------------------------------------------------------------------------------------------------------------ 已載入外掛:fastestmirror, langpacks
正在解決依賴關係
--> 正在檢查事務
---> 軟體包 mariadb-libs.x86_64.1.5.5.44-2.el7.centos 將被 刪除
--> 正在處理依賴關係 libmysqlclient.so.18()(64bit),它被軟體包 2:postfix-2.10.1-6.el7.x86_64 需要
--> 正在處理依賴關係 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被軟體包 2:postfix-2.10.1-6.el7.x86_64 需要
--> 正在檢查事務
---> 軟體包 postfix.x86_64.2.2.10.1-6.el7 將被 刪除
--> 解決依賴關係完成
base/7/x86_64 | 3.6 kB 00:00:00
extras/7/x86_64 | 3.4 kB 00:00:00
updates/7/x86_64 | 3.4 kB 00:00:00 依賴關係解決 =======================================================================================================================================
Package 架構 版本 源 大小
=======================================================================================================================================
正在刪除:
mariadb-libs x86_64 1:5.5.44-2.el7.centos @anaconda 4.4 M
為依賴而移除:
postfix x86_64 2:2.10.1-6.el7 @anaconda 12 M 事務概要
=======================================================================================================================================
移除 1 軟體包 (+1 依賴軟體包) 安裝大小:17 M
是否繼續?[y/N]:y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 資料庫已被非 yum 程式修改。
** 發現 4 個已存在的 RPM 資料庫問題, 'yum check' 輸出如下:
icedtea-web-1.6.1-4.el7.x86_64 有缺少的需求 java-1.8.0-openjdk
jline-1.0-8.el7.noarch 有缺少的需求 java >= ('0', '1.5', None)
1:libreoffice-core-4.3.7.2-5.el7.x86_64 有缺少的需求 java-headless >= ('1', '1.6', None)
1:libreoffice-ure-4.3.7.2-5.el7.x86_64 有缺少的需求 libjvm.so()(64bit)
正在刪除 : 2:postfix-2.10.1-6.el7.x86_64 1/2
正在刪除 : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 2/2
驗證中 : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 1/2
驗證中 : 2:postfix-2.10.1-6.el7.x86_64 2/2 刪除:
mariadb-libs.x86_64 1:5.5.44-2.el7.centos 作為依賴被刪除:
postfix.x86_64 2:2.10.1-6.el7 完畢! ------------------------------------------------------------------------------------------------------------------------------------------------------------ 類似的錯誤,都可以先試試徹底從centos中解除安裝mysql。
3.2然後再重新安裝依次安裝吧: # rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-common-5.7.18-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 金鑰 ID 5072e1f5: NOKEY
準備中... ################################# [100%]
正在升級/安裝...
1:mysql-community-common-5.7.18-1.e################################# [100%] # rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-libs-5.7.18-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 金鑰 ID 5072e1f5: NOKEY
準備中... ################################# [100%]
正在升級/安裝...
1:mysql-community-libs-5.7.18-1.el7################################# [100%]
# rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-client-5.7.18-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 金鑰 ID 5072e1f5: NOKEY
準備中... ################################# [100%]
正在升級/安裝...
1:mysql-community-client-5.7.18-1.e################################# [100%]
# rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-server-5.7.18-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 金鑰 ID 5072e1f5: NOKEY
準備中... ################################# [100%]
正在升級/安裝...
1:mysql-community-server-5.7.18-1.e################################# [100%]
# rpm -ivh mysql-community-devel-5.7.18-1.el7.x86_64.rpm (可選安裝)
警告:mysql-community-devel-5.7.18-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 金鑰 ID 5072e1f5: NOKEY
準備中... ################################# [100%]
正在升級/安裝...
1:mysql-community-devel-5.7.18-1.el################################# [100%]
四、啟動:
# systemctl start mysqld
檢視狀態:
# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 六 2017-05-13 13:39:56 CST; 28min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 5791 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 5714 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 5795 (mysqld)
CGroup: /system.slice/mysqld.service
└─5795 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid 5月 13 13:39:28 hostaa systemd[1]: Starting MySQL Server...
5月 13 13:39:56 hostaa systemd[1]: Started MySQL Server.
5月 13 14:05:49 hostaa systemd[1]: Started MySQL Server.
五、登陸: 這種方式安裝好後,會再my.cnf檔案中自動生成一個密碼,執行看一下吧: # cat /var/log/mysqld.log | grep password
2017-05-13T05:39:44.497086Z 1 [Note] A temporary password is generated for [email protected]: pKsO:Jin<4f% 密碼就是這麼複雜,複製吧,不然手輸還容易出錯。 登陸:#mysql -u root -p Enter password: pKsO:Jin<4f% Welcome to the MySQL monitor. Commands end with ; or \g
Your MySQL connection id is 7
Server version: 5.7.18 Copyright (c) 2000, 2017, 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> .--登陸成功,但是這時候,還不能做任何事情。隨便你做什麼都會提示你: ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. 那就來reset吧: mysql> SET PASSWORD = PASSWORD('Mysql5718');
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements (密碼過於簡單,必須大寫,小寫,數字,符號)
mysql> SET PASSWORD = PASSWORD('Mysql5718%');
Query OK, 0 rows affected, 1 warning (0.00 sec) 好了,現在終於可以操作了: mysql> create database roger;
Query OK, 1 row affected (0.01 sec)
mysql> use roger;
Database changed
mysql> 額外:一般自己裝個mysql就是用來測試的,結果密碼還那麼麻煩,哪天忘記了都有可能,想要設定簡單的密碼,把密碼安全級別設定低一點吧: mysql> set global validate_password_policy=0;//0最低,1中級,2最強驗證級別 Query OK, 0 rows affected (0.00 sec)
Policy | Tests Performed |
---|---|
0 or LOW |
Length |
1 or MEDIUM |
Length; numeric, lowercase/uppercase, and special characters |
2 or STRONG |
Length; numeric, lowercase/uppercase, and special characters; dictionary file |
六、授權遠端連線: mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Mysql5718%' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec) 這樣,我們就可以在其他電腦上的mysql客戶端遠端連線linux上的mysql資料庫了:(例如在win cmd裡面) C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin>mysql -u root -pMysql5718% -h 192.168.231.8 -D roger
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.7.18 MySQL Community Server (GPL) Copyright (c) 2000, 2011, 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> (如果連不上,看看是不是防火牆開著的。)
(寫得很用心,看完了,請留下你們得足跡吧!)