CentOS7.4使用rpm包安裝mysql5.7.17

甲骨文技術支援發表於2017-11-03
作業系統環境:

  1. CentOS Linux release 7.4.1708 (Core)
MySQL版本:5.7.17
 
一,解除安裝mariadb-lib

  1. [root@iZ2ze6jo3o3bqbcongnypqZ lib]# rpm -qa|grep mariadb
  2. mariadb-libs-5.5.56-2.el7.x86_64 

  3. [root@iZ2ze6jo3o3bqbcongnypqZ ~]# yum -y remove mariadb-libs-5.5.56-2.el7.x86_64
  4. Loaded plugins: fastestmirror
  5. Resolving Dependencies
  6. --> Running transaction check
  7. ---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be erased
  8. --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
  9. --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
  10. --> Running transaction check
  11. ---> Package postfix.x86_64 2:2.10.1-6.el7 will be erased
  12. --> Processing Dependency: /usr/sbin/sendmail for package: redhat-lsb-core-4.1-27.el7.centos.1.x86_64
  13. --> Restarting Dependency Resolution with new changes.
  14. --> Running transaction check
  15. ---> Package redhat-lsb-core.x86_64 0:4.1-27.el7.centos.1 will be erased
  16. --> Finished Dependency Resolution

  17. Dependencies Resolved

  18. ==============================================================================================================================================================================================================================================================================
  19.  Package Arch Version Repository Size
  20. ==============================================================================================================================================================================================================================================================================
  21. Removing:
  22.  mariadb-libs x86_64 1:5.5.56-2.el7 @base 4.4 M
  23. Removing for dependencies:
  24.  postfix x86_64 2:2.10.1-6.el7 @anaconda 12 M
  25.  redhat-lsb-core x86_64 4.1-27.el7.centos.@base 45 k

  26. Transaction Summary
  27. ==============================================================================================================================================================================================================================================================================
  28. Remove 1 Package (+2 Dependent packages)

  29. Installed size: 17 M
  30. Downloading packages:
  31. Running transaction check
  32. Running transaction test
  33. Transaction test succeeded
  34. Running transaction
  35.   Erasing : redhat-lsb-core-4.1-27.el7.centos.1.x86_64 1/
  36.   Erasing : 2:postfix-2.10.1-6.el7.x86_64 2/
  37.   Erasing : 1:mariadb-libs-5.5.56-2.el7.x86_64 3/
  38.   Verifying : 1:mariadb-libs-5.5.56-2.el7.x86_64 1/
  39.   Verifying : 2:postfix-2.10.1-6.el7.x86_64 2/
  40.   Verifying : redhat-lsb-core-4.1-27.el7.centos.1.x86_64 3/

  41. Removed:
  42.   mariadb-libs.x86_64 1:5.5.56-2.el7 

  43. Dependency Removed:
  44.   postfix.x86_64 2:2.10.1-6.el7 redhat-lsb-core.x86_64 0:4.1-27.el7.centos.

  45. Complete!

二,下載mysql5.7.17rpm安裝包,具體是mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar

  1. wget https://downloads.mysql.com/archives/get/file/mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar
三,解壓


  1. [root@iZ2ze6jo3o3bqbcongnyppZ ~]# tar -xvf mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar

  1. -rw-r--r-- 1 7155 31415 25037548 Nov 30 2016 mysql-community-client-5.7.17-1.el7.x86_64.rpm
  2. -rw-r--r-- 1 7155 31415 277812 Nov 30 2016 mysql-community-common-5.7.17-1.el7.x86_64.rpm
  3. -rw-r--r-- 1 7155 31415 3774276 Nov 30 2016 mysql-community-devel-5.7.17-1.el7.x86_64.rpm
  4. -rw-r--r-- 1 7155 31415 45474744 Nov 30 2016 mysql-community-embedded-5.7.17-1.el7.x86_64.rpm
  5. -rw-r--r-- 1 7155 31415 23925668 Nov 30 2016 mysql-community-embedded-compat-5.7.17-1.el7.x86_64.rpm
  6. -rw-r--r-- 1 7155 31415 126047424 Nov 30 2016 mysql-community-embedded-devel-5.7.17-1.el7.x86_64.rpm
  7. -rw-r--r-- 1 7155 31415 2237116 Nov 30 2016 mysql-community-libs-5.7.17-1.el7.x86_64.rpm
  8. -rw-r--r-- 1 7155 31415 2112724 Nov 30 2016 mysql-community-libs-compat-5.7.17-1.el7.x86_64.rpm
  9. -rw-r--r-- 1 7155 31415 54571580 Nov 30 2016 mysql-community-minimal-debuginfo-5.7.17-1.el7.x86_64.rpm
  10. -rw-r--r-- 1 7155 31415 169496800 Nov 30 2016 mysql-community-server-5.7.17-1.el7.x86_64.rpm
  11. -rw-r--r-- 1 7155 31415 14478292 Nov 30 2016 mysql-community-server-minimal-5.7.17-1.el7.x86_64.rpm
  12. -rw-r--r-- 1 7155 31415 116682212 Nov 30 2016 mysql-community-test-5.7.17-1.el7.x86_64.rpm
四,安裝

要按照如下順序安裝

  1. [root@iZ2ze6jo3o3bqbcongnyppZ ~]# rpm -ivh mysql-community-common-5.7.17-1.el7.x86_64.rpm
  2. [root@iZ2ze6jo3o3bqbcongnyppZ ~]# rpm -ivh mysql-community-libs-5.7.17-1.el7.x86_64.rpm
  3. [root@iZ2ze6jo3o3bqbcongnyppZ ~]# rpm -ivh mysql-community-libs-compat-5.7.17-1.el7.x86_64
  4. [root@iZ2ze6jo3o3bqbcongnyppZ ~]# rpm -ivh mysql-community-devel-5.7.17-1.el7.x86_64
  5. [root@iZ2ze6jo3o3bqbcongnyppZ ~]# rpm -ivh mysql-community-client-5.7.17-1.el7.x86_64.rpm
  6. [root@iZ2ze6jo3o3bqbcongnyppZ ~]# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm
在安裝server的時候報錯


  1. [root@iZ2ze6jo3o3bqbcongnypoZ ~]# rpm -ivh mysql-community-server-5.7.17-1.el7.x86_64.rpm
  2. warning: mysql-community-server-5.7.17-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
  3. error: Failed dependencies:
  4.     libaio.so.1()(64bit) is needed by mysql-community-server-5.7.17-1.el7.x86_64
  5.     libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.17-1.el7.x86_64
  6.     libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.17-1.el7.x86_64

缺少libaio.so,用yum安裝上:


  1. [root@iZ2ze6jo3o3bqbcongnypoZ ~]# yum install libaio*
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4.  * base: mirrors.cloud.aliyuncs.com
  5.  * epel: mirrors.cloud.aliyuncs.com
  6.  * extras: mirrors.cloud.aliyuncs.com
  7.  * updates: mirrors.cloud.aliyuncs.com
  8. Resolving Dependencies
  9. --> Running transaction check
  10. ---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
  11. ---> Package libaio-devel.x86_64 0:0.3.109-13.el7 will be installed
  12. --> Finished Dependency Resolution

  13. Dependencies Resolved

  14. ==============================================================================================================================================================================================================================================================================
  15.  Package Arch Version Repository Size
  16. ==============================================================================================================================================================================================================================================================================
  17. Installing:
  18.  libaio x86_64 0.3.109-13.el7 base 24 k
  19.  libaio-devel x86_64 0.3.109-13.el7 base 13 k

  20. Transaction Summary
  21. ==============================================================================================================================================================================================================================================================================
  22. Install 2 Packages

  23. Total download size: 37 k
  24. Installed size: 46 k
  25. Is this ok [y/d/N]: y
  26. Downloading packages:
  27. (1/2): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00 
  28. (2/2): libaio-devel-0.3.109-13.el7.x86_64.rpm | 13 kB 00:00:00 
  29. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  30. Total 243 kB/| 37 kB 00:00:00 
  31. Running transaction check
  32. Running transaction test
  33. Transaction test succeeded
  34. Running transaction
  35. Warning: RPMDB altered outside of yum.
  36.   Installing : libaio-0.3.109-13.el7.x86_64 1/
  37.   Installing : libaio-devel-0.3.109-13.el7.x86_64 2/
  38.   Verifying : libaio-0.3.109-13.el7.x86_64 1/
  39.   Verifying : libaio-devel-0.3.109-13.el7.x86_64 2/

  40. Installed:
  41.   libaio.x86_64 0:0.3.109-13.el7 libaio-devel.x86_64 0:0.3.109-13.el7 

  42. Complete!

五,找到密碼:


找到資料庫的初始密碼,最後一行冒號後面的就是

  1. [root@iZ2ze6jo3o3bqbcongnypqZ mysql]# cat /var/log/mysqld.log 
  2. 2017-11-03T08:41:25.257336Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  3. 2017-11-03T08:41:26.329912Z 0 [Warning] InnoDB: New log files created, LSN=45790
  4. 2017-11-03T08:41:26.543807Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
  5. 2017-11-03T08:41:26.566468Z 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: c79a2e4b-c072-11e7-b809-00163e0ad76e.
  6. 2017-11-03T08:41:26.570349Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  7. 2017-11-03T08:41:26.571065Z 1 [Note] A temporary password is generated for root@localhost: 7PkQ:l<p2cpH

六,啟動mysql


  1. [root@iZ2ze6jo3o3bqbcongnyppZ ~]# systemctl start mysqld.service
  2. [root@iZ2ze6jo3o3bqbcongnyppZ ~]# mysql -uroot -p
  3. Enter password: 
  4. Welcome to the MySQL monitor. Commands end with ; or \g.
  5. Your MySQL connection id is 3
  6. Server version: 5.7.17

  7. Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

  8. Oracle is a registered trademark of Oracle Corporation and/or its
  9. affiliates. Other names may be trademarks of their respective
  10. owners.

  11. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

  12. mysql>
七,修改密碼

臨時密碼過期了,需要修改


  1. mysql> show databases;
  2. ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

用如下命令修改


  1. ALTER USER 'root'@'localhost' IDENTIFIED BY 'yournew_password';

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/20893244/viewspace-2146801/,如需轉載,請註明出處,否則將追究法律責任。

相關文章