久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

centos7.3 安裝mysql5.7.18的示例

135次閱讀
沒有評論

共計 12161 個字符,預計需要花費 31 分鐘才能閱讀完成。

自動寫代碼機器人,免費開通

丸趣 TV 小編給大家分享一下 centos7.3 安裝 mysql5.7.18 的示例,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

1 查看 Linux 發行版本

[root@typecodes ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

2 下載 MySQL 官方的 Yum Repository

根據 Linux 發行版本(CentOS、Fedora 都屬于紅帽系),從 mysql 官方(http://dev.mysql.com/downloads/repo/yum/)獲取 Yum Repository。

[root@typecodes ~]# wget -i http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
--2016-02-03 18:36:02-- http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm [following]
--2016-02-03 18:36:04-- http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 104.102.164.25
Connecting to repo.mysql.com (repo.mysql.com)|104.102.164.25|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8984 (8.8K) [application/x-redhat-package-manager]
Saving to: ‘mysql57-community-release-el7-7.noarch.rpm 
100%[=============================================================================================================================] 8,984 --.-K/s in 0s
2016-02-03 18:36:07 (68.4 MB/s) - ‘mysql57-community-release-el7-7.noarch.rpm  saved [8984/8984]
3  安裝 MySQL 的 Yum Repository
安裝完 MySQL 的 Yum Repository,每次執行 yum update 都會檢查 MySQL 是否更新。[root@typecodes ~]# yum -y install mysql57-community-release-el7-7.noarch.rpm
Loaded plugins: axelget, fastestmirror, langpacks
Examining mysql57-community-release-el7-7.noarch.rpm: mysql57-community-release-el7-7.noarch
Marking mysql57-community-release-el7-7.noarch.rpm to be installed
Resolving Dependencies
--  Running transaction check
---  Package mysql57-community-release.noarch 0:el7-7 will be installed
--  Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================
 Package Arch Version Repository Size
=======================================================================================================================================================================
Installing:
 mysql57-community-release noarch el7-7 /mysql57-community-release-el7-7.noarch 7.8 k
Transaction Summary
=======================================================================================================================================================================
Install 1 Package
Total size: 7.8 k
Installed size: 7.8 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : mysql57-community-release-el7-7.noarch 1/1 
 Verifying : mysql57-community-release-el7-7.noarch 1/1
Installed:
 mysql57-community-release.noarch 0:el7-7
Complete!

3 安裝 MySQL 數據庫的服務器版本

[root@typecodes ~]# yum -y install mysql-community-server
Loaded plugins: axelget, fastestmirror, langpacks
No metadata available for base
No metadata available for epel
No metadata available for extras
repomd.xml | 2.5 kB 00:00:00 
update mysql-connectors-community metadata successfully
repomd.xml | 2.5 kB 00:00:00 
update mysql-tools-community metadata successfully
repomd.xml | 2.5 kB 00:00:00 
update mysql57-community metadata successfully
No metadata available for updates
mysql-connectors-community | 2.5 kB 00:00:00 
mysql-tools-community | 2.5 kB 00:00:00 
mysql57-community | 2.5 kB 00:00:00 
(1/3): mysql-tools-community/x86_64/primary_db | 24 kB 00:00:01 
(2/3): mysql57-community/x86_64/primary_db | 28 kB 00:00:01 
(3/3): mysql-connectors-community/x86_64/primary_db | 8.6 kB 00:00:02 
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.neusoft.edu.cn
 * extras: mirrors.163.com
 * updates: mirrors.163.com
Resolving Dependencies
--  Running transaction check
---  Package mysql-community-server.x86_64 0:5.7.10-1.el7 will be installed
--  Processing Dependency: mysql-community-common(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--  Processing Dependency: mysql-community-client(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
--  Running transaction check
---  Package mysql-community-client.x86_64 0:5.7.10-1.el7 will be installed
--  Processing Dependency: mysql-community-libs(x86-64) = 5.7.10-1.el7 for package: mysql-community-client-5.7.10-1.el7.x86_64
---  Package mysql-community-common.x86_64 0:5.7.10-1.el7 will be installed
--  Running transaction check
---  Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be obsoleted
--  Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
--  Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
---  Package mysql-community-libs.x86_64 0:5.7.10-1.el7 will be obsoleting
--  Running transaction check
---  Package mysql-community-libs-compat.x86_64 0:5.7.10-1.el7 will be obsoleting
--  Finished Dependency Resolution
Dependencies Resolved
=======================================================================================================================================================================
 Package Arch Version Repository Size
=======================================================================================================================================================================
Installing:
 mysql-community-libs x86_64 5.7.10-1.el7 mysql57-community 2.2 M
 replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 mysql-community-libs-compat x86_64 5.7.10-1.el7 mysql57-community 2.0 M
 replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos
 mysql-community-server x86_64 5.7.10-1.el7 mysql57-community 142 M
Installing for dependencies:
 mysql-community-client x86_64 5.7.10-1.el7 mysql57-community 24 M
 mysql-community-common x86_64 5.7.10-1.el7 mysql57-community 269 k
Transaction Summary
=======================================================================================================================================================================
Install 3 Packages (+2 Dependent packages)
Total download size: 171 M
Downloading packages:
mysql-community-server-5.7.10-1.el7.x86_64.rpm | 142 MB 00:03:42 
mysql-community-libs-compat-5.7.10-1.el7.x86_64.rpm | 2.0 MB 00:00:03 
mysql-community-libs-5.7.10-1.el7.x86_64.rpm | 2.2 MB 00:00:05 
mysql-community-client-5.7.10-1.el7.x86_64.rpm | 24 MB 00:00:41 
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.10-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY00 ETA 
Public key for mysql-community-common-5.7.10-1.el7.x86_64.rpm is not installed
mysql-community-common-5.7.10-1.el7.x86_64.rpm | 269 kB 00:00:01 
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-7.noarch (@/mysql57-community-release-el7-7.noarch)
 From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : mysql-community-common-5.7.10-1.el7.x86_64 1/6 
 Installing : mysql-community-libs-5.7.10-1.el7.x86_64 2/6 
 Installing : mysql-community-client-5.7.10-1.el7.x86_64 3/6 
 Installing : mysql-community-server-5.7.10-1.el7.x86_64 4/6 
 Installing : mysql-community-libs-compat-5.7.10-1.el7.x86_64 5/6 
 Erasing : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 6/6 
 Verifying : mysql-community-server-5.7.10-1.el7.x86_64 1/6 
 Verifying : mysql-community-libs-compat-5.7.10-1.el7.x86_64 2/6 
 Verifying : mysql-community-common-5.7.10-1.el7.x86_64 3/6 
 Verifying : mysql-community-libs-5.7.10-1.el7.x86_64 4/6 
 Verifying : mysql-community-client-5.7.10-1.el7.x86_64 5/6 
 Verifying : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64 6/6
Installed:
 mysql-community-libs.x86_64 0:5.7.10-1.el7 mysql-community-libs-compat.x86_64 0:5.7.10-1.el7 mysql-community-server.x86_64 0:5.7.10-1.el7
Dependency Installed:
 mysql-community-client.x86_64 0:5.7.10-1.el7 mysql-community-common.x86_64 0:5.7.10-1.el7
Replaced:
 mariadb-libs.x86_64 1:5.5.44-2.el7.centos
Complete!
[root@typecodes ~]# clear

最后的截圖:

centos7.3 安裝 mysql5.7.18 的示例

4 啟動數據庫:

[root@typecodes ~]# systemctl start mysqld.service

然后使用命令 systemctl status mysqld.service 查看 MySQL 數據庫啟動后的服務狀態:

centos7.3 安裝 mysql5.7.18 的示例

5 獲取初始密碼

使用 YUM 安裝并啟動 MySQL 服務后,MySQL 進程會自動在進程日志中打印 root 用戶的初始密碼:

####### 從 mysql 進程日志中獲取 root 用戶的初始密碼:ra%yk7urCBIh
[root@typecodes ~]# grep  password  /var/log/mysqld.log
2016-02-03T10:42:17.272166Z 1 [Note] A temporary password is generated for root@localhost: ra%yk7urCBIh
2016-02-03T10:42:36.776875Z 2 [Note] Access denied for user  root @ localhost  (using password: NO)
2016-02-03T10:42:52.063138Z 3 [Note] Access denied for user  root @ localhost  (using password: NO)
2016-02-03T10:42:57.564373Z 4 [Note] Access denied for user  root @ localhost  (using password: NO)
2016-02-03T10:43:01.477007Z 5 [Note] Access denied for user  root @ localhost  (using password: NO)
2016-02-03T10:46:03.642008Z 6 [Note] Access denied for user  root @ localhost  (using password: NO)
2016-02-03T10:46:11.217889Z 7 [Note] Access denied for user  root @ localhost  (using password: NO)
2016-02-03T10:47:44.755199Z 0 [Note] Shutting down plugin  validate_password 
2016-02-03T10:47:46.505844Z 0 [Note] Shutting down plugin  sha256_password 
2016-02-03T10:47:46.505851Z 0 [Note] Shutting down plugin  mysql_native_password

6 修改 root 用戶密碼

使用小節 5 中獲取的 root 用戶的初始密碼,然后進行修改:

set global validate_password_policy =0;// 默認是 1,即 MEDIUM,所以剛開始設置的密碼必須符合長度,且必須含有數字,小寫或大寫字母,特殊字符。

set global validate_password_length=4;// 指定了密碼中數據的長度
alter user root@localhost identified by  crow // 修改密碼 

增加遠程訪問權限

GRANT ALL PRIVILEGES ON *.* TO  root @ %  IDENTIFIED BY  crow  WITH GRANT OPTION;
FLUSH PRIVILEGES;

退出 mysql,然后重啟服務

systemctl restart mysqld

防火墻打開 3306 端口

firewall-cmd --zone=public --add-port=3306/tcp --permanent

重啟防火墻

firewall-cmd --reload
[root@typecodes ~]# mysql -uroot -p
Enter password: ####### 輸入默認的 root 密碼后回車
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10
Copyright (c) 2000, 2015, 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  ALTER USER  root @ localhost  IDENTIFIED BY  new password 
Query OK, 0 rows affected (0.00 sec)
mysql  exit
Bye

7 安裝完畢

至此,使用在 CentOS7 中使用 YUM 方法安裝 MySQL5.7.10 數據庫完畢。如下所示,可以使用新的 root 密碼登陸 MySQL 了。

[root@typecodes ~]# mysql -uroot -ppassword
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.10 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, 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  use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql  show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql  clear
mysql  exit
[root@typecodes ~]# clear

附錄 1:查看 MySQL 數據庫的配置信息

MySQL 的配置文件依然是 /etc/my.cnf,其它安裝信息可以通過 mysql_config 命令查看。其中,動態庫文件存放在 /usr/lib64/mysql 目錄下。

centos7.3 安裝 mysql5.7.18 的示例

附錄 2:對于 C /C++ 等開發者

由于需要用到類似 mysql.h 等頭文件,需要執行下面的命令安裝 mysql 開發版本即可。

[root@typecodes ~]# yum -y install mysql-community-devel

附錄 3:刪除 MySQL 的 Repository

因為小節 3 中安裝了 MySQL 的 Yum Repository,所以以后每次執行 yum 操作時,都會去檢查更新。如果想要去掉這種自動檢查操作的話,可以使用如下命令卸載 MySQL 的 Repository 即可。

[root@typecodes ~]# yum -y remove mysql57-community-release-el7-7.noarch
update 2017.04.10 11:10

使用上面的 yum 方法也可以安裝目前 mysql 官網上最新的版本 mysql5.7.18。只要替換小節 2 中 rmp 包的版本即可,后續操作步驟不變。

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

看完了這篇文章,相信你對“centos7.3 安裝 mysql5.7.18 的示例”有了一定的了解,如果想了解更多相關知識,歡迎關注丸趣 TV 行業資訊頻道,感謝各位的閱讀!

向 AI 問一下細節

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-12-16發表,共計12161字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 胶南市| 酉阳| 花莲县| 锡林郭勒盟| 堆龙德庆县| 桐庐县| 三明市| 三门县| 西乌珠穆沁旗| 化州市| 长泰县| 夏河县| 淮滨县| 东乌珠穆沁旗| 柏乡县| 阳东县| 宜良县| 克东县| 伊宁县| 呼和浩特市| 容城县| 历史| 肥城市| 息烽县| 石嘴山市| 炎陵县| 黄石市| 常宁市| 肥城市| 普兰店市| 清丰县| 江山市| 宜春市| 宜兰县| 永顺县| 海阳市| 密山市| 谢通门县| 德阳市| 临江市| 江门市|