CentOS 7.6 安装 Mysql 5.7
生活随笔
收集整理的這篇文章主要介紹了
CentOS 7.6 安装 Mysql 5.7
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、查看CentOS版本
Mysql的版本必須要和CentOS的版本對應!查看CentOS版本的指令如下:
cat /etc/redhat-release
二、下載yum源包
wget http://repo.mysql.com/mysql57-community-release-el7.rpm
三、安裝rpm包
sudo rpm -Uvh mysql57-community-release-el7.rpm
四、安裝Mysql服務
[root@lanxinmeichen0613 mysql]# sudo yum install mysql-community-server
Loaded plugins: fastestmirror, versionlock
Determining fastest mirrors
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
mysql-connectors-community | 2.6 kB 00:00:00
mysql-tools-community | 2.6 kB 00:00:00
mysql57-community | 2.6 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/7): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/7): extras/7/x86_64/primary_db | 253 kB 00:00:00
(3/7): mysql-tools-community/x86_64/primary_db | 98 kB 00:00:00
(4/7): mysql-connectors-community/x86_64/primary_db | 114 kB 00:00:00
(5/7): base/7/x86_64/primary_db | 6.1 MB 00:00:00
(6/7): updates/7/x86_64/primary_db | 27 MB 00:00:00
(7/7): mysql57-community/x86_64/primary_db | 361 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.44-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.44-1.el7 for package: mysql-community-server-5.7.44-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.44-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.44-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.44-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.44-1.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.44-1.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
mysql-community-server x86_64 5.7.44-1.el7 mysql57-community 184 M
Installing for dependencies:
mysql-community-client x86_64 5.7.44-1.el7 mysql57-community 31 M
mysql-community-common x86_64 5.7.44-1.el7 mysql57-community 313 k
mysql-community-libs x86_64 5.7.44-1.el7 mysql57-community 3.0 M Transaction Summary
====================================================================================================================================
Install 1 Package (+3 Dependent packages) Total download size: 219 M
Installed size: 930 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.44-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Public key for mysql-community-common-5.7.44-1.el7.x86_64.rpm is not installed
(1/4): mysql-community-common-5.7.44-1.el7.x86_64.rpm | 313 kB 00:00:00
(2/4): mysql-community-libs-5.7.44-1.el7.x86_64.rpm | 3.0 MB 00:00:00
(3/4): mysql-community-client-5.7.44-1.el7.x86_64.rpm | 31 MB 00:00:04
(4/4): mysql-community-server-5.7.44-1.el7.x86_64.rpm | 184 MB 00:00:18
------------------------------------------------------------------------------------------------------------------------------------
Total 11 MB/s | 219 MB 00:00:19
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql57-community-release-el7-11.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y Public key for mysql-community-server-5.7.44-1.el7.x86_64.rpm is not installed Failing package is: mysql-community-server-5.7.44-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
五、處理一下報錯
[root@lanxinmeichen0613 mysql]# sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
六、繼續安裝Mysql服務
[root@lanxinmeichen0613 mysql]# sudo yum install -y mysql-community-server
Loaded plugins: fastestmirror, versionlock
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.44-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.44-1.el7 for package: mysql-community-server-5.7.44-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.44-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.44-1.el7 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.44-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.7.44-1.el7 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.44-1.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved ====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
mysql-community-server x86_64 5.7.44-1.el7 mysql57-community 184 M
Installing for dependencies:
mysql-community-client x86_64 5.7.44-1.el7 mysql57-community 31 M
mysql-community-common x86_64 5.7.44-1.el7 mysql57-community 313 k
mysql-community-libs x86_64 5.7.44-1.el7 mysql57-community 3.0 M Transaction Summary
====================================================================================================================================
Install 1 Package (+3 Dependent packages) Total size: 219 M
Installed size: 930 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : mysql-community-common-5.7.44-1.el7.x86_64 1/4
Installing : mysql-community-libs-5.7.44-1.el7.x86_64 2/4
Installing : mysql-community-client-5.7.44-1.el7.x86_64 3/4
Installing : mysql-community-server-5.7.44-1.el7.x86_64 4/4
Verifying : mysql-community-server-5.7.44-1.el7.x86_64 1/4
Verifying : mysql-community-client-5.7.44-1.el7.x86_64 2/4
Verifying : mysql-community-libs-5.7.44-1.el7.x86_64 3/4
Verifying : mysql-community-common-5.7.44-1.el7.x86_64 4/4 Installed:
mysql-community-server.x86_64 0:5.7.44-1.el7 Dependency Installed:
mysql-community-client.x86_64 0:5.7.44-1.el7 mysql-community-common.x86_64 0:5.7.44-1.el7
mysql-community-libs.x86_64 0:5.7.44-1.el7 Complete!
七、啟動Mysql服務
[root@lanxinmeichen0613 mysql]# systemctl start mysqld.service
八、獲取臨時密碼
[root@lanxinmeichen0613 mysql]# sudo grep 'temporary password' /var/log/mysqld.log
2024-06-14T09:00:04.412228Z 1 [Note] A temporary password is generated for root@localhost: _izgQQt_7/OG
九、修改密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'f21des';
十、修改遠程
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '21des';
Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL ON *.* TO 'root'@'%';
Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
總結
以上是生活随笔為你收集整理的CentOS 7.6 安装 Mysql 5.7的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 35.2K star!双链笔记+知识图谱
- 下一篇: dev c++基础操作