CentOS-7系統下安裝MySQL5.6

来源:http://www.cnblogs.com/joah-q/archive/2017/11/02/7774274.html
-Advertisement-
Play Games

好像在CentOS 7系統中,預設安裝的mysql是它的分支mariadb。所以不能像CentOS 6.3那樣安裝,如下: 所以按如下步驟安裝: 1.下載rpm包 2.查看當前可用的mysql安裝資源 3.yum安裝 安裝完成。 4.啟動MySQL 5.查看運行狀態 到這應該沒有問題了,接下來就是怎 ...


好像在CentOS 7系統中,預設安裝的mysql是它的分支mariadb。所以不能像CentOS-6.3那樣安裝,如下:

[root@izwz ~]# yum -y install mysql mysql-server mysql-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package 1:mariadb-5.5.56-2.el7.x86_64 already installed and latest version
No package mysql-server available.
Package 1:mariadb-devel-5.5.56-2.el7.x86_64 already installed and latest version
Nothing to do

所以按如下步驟安裝:

1.下載rpm包

[root@izwz ~]# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Retrieving http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-release-el7-5    ################################# [100%]

2.查看當前可用的mysql安裝資源

[root@izwz ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community                  42
mysql-tools-community/x86_64      MySQL Tools Community                       51
mysql56-community/x86_64          MySQL 5.6 Community Server                 361

3.yum安裝

[root@izwz ~]# yum -y install mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.38-2.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.38-2.el7 for package: mysql-community-server-5.6.38-2.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.6.10 for package: mysql-community-server-5.6.38-2.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: mysql-community-server-5.6.38-2.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: mysql-community-server-5.6.38-2.el7.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: mysql-community-server-5.6.38-2.el7.x86_64
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package mariadb.x86_64 1:5.5.56-2.el7 will be obsoleted
---> Package mysql-community-client.x86_64 0:5.6.38-2.el7 will be obsoleting
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.6.10 for package: mysql-community-client-5.6.38-2.el7.x86_64
---> Package mysql-community-common.x86_64 0:5.6.38-2.el7 will be installed
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.56-2.el7 will be obsoleted
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.56-2.el7 for package: 1:mariadb-devel-5.5.56-2.el7.x86_64
---> Package mysql-community-libs.x86_64 0:5.6.38-2.el7 will be obsoleting
--> Running transaction check
---> Package mariadb-devel.x86_64 1:5.5.56-2.el7 will be obsoleted
---> Package mysql-community-devel.x86_64 0:5.6.38-2.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================
 Package                        Arch           Version                 Repository                 Size
=======================================================================================================
Installing:
 mysql-community-client         x86_64         5.6.38-2.el7            mysql56-community          19 M
     replacing  mariadb.x86_64 1:5.5.56-2.el7
 mysql-community-devel          x86_64         5.6.38-2.el7            mysql56-community         3.4 M
     replacing  mariadb-devel.x86_64 1:5.5.56-2.el7
 mysql-community-libs           x86_64         5.6.38-2.el7            mysql56-community         2.0 M
     replacing  mariadb-libs.x86_64 1:5.5.56-2.el7
 mysql-community-server         x86_64         5.6.38-2.el7            mysql56-community          59 M
Installing for dependencies:
 libaio                         x86_64         0.3.109-13.el7          base                       24 k
 mysql-community-common         x86_64         5.6.38-2.el7            mysql56-community         257 k

Transaction Summary
=======================================================================================================
Install  4 Packages (+2 Dependent packages)

Total download size: 84 M
Downloading packages:
(1/6): libaio-0.3.109-13.el7.x86_64.rpm                                         |  24 kB  00:00:00     
warning: /var/cache/yum/x86_64/7/mysql56-community/packages/mysql-community-common-5.6.38-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-common-5.6.38-2.el7.x86_64.rpm is not installed
(2/6): mysql-community-common-5.6.38-2.el7.x86_64.rpm                           | 257 kB  00:00:00     
(3/6): mysql-community-devel-5.6.38-2.el7.x86_64.rpm                            | 3.4 MB  00:00:00     
(4/6): mysql-community-libs-5.6.38-2.el7.x86_64.rpm                             | 2.0 MB  00:00:00     
(5/6): mysql-community-client-5.6.38-2.el7.x86_64.rpm                           |  19 MB  00:00:02     
(6/6): mysql-community-server-5.6.38-2.el7.x86_64.rpm                           |  59 MB  00:00:05     
-------------------------------------------------------------------------------------------------------
Total                                                                   12 MB/s |  84 MB  00:00:07     
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <[email protected]>"
 Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
 Package    : mysql-community-release-el7-5.noarch (installed)
 From       : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : mysql-community-common-5.6.38-2.el7.x86_64                                          1/9 
  Installing : mysql-community-libs-5.6.38-2.el7.x86_64                                            2/9 
  Installing : mysql-community-client-5.6.38-2.el7.x86_64                                          3/9 
  Installing : libaio-0.3.109-13.el7.x86_64                                                        4/9 
  Installing : mysql-community-server-5.6.38-2.el7.x86_64                                          5/9 
  Installing : mysql-community-devel-5.6.38-2.el7.x86_64                                           6/9 
  Erasing    : 1:mariadb-devel-5.5.56-2.el7.x86_64                                                 7/9 
  Erasing    : 1:mariadb-5.5.56-2.el7.x86_64                                                       8/9 
  Erasing    : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                  9/9 
  Verifying  : mysql-community-libs-5.6.38-2.el7.x86_64                                            1/9 
  Verifying  : mysql-community-client-5.6.38-2.el7.x86_64                                          2/9 
  Verifying  : mysql-community-devel-5.6.38-2.el7.x86_64                                           3/9 
  Verifying  : mysql-community-server-5.6.38-2.el7.x86_64                                          4/9 
  Verifying  : mysql-community-common-5.6.38-2.el7.x86_64                                          5/9 
  Verifying  : libaio-0.3.109-13.el7.x86_64                                                        6/9 
  Verifying  : 1:mariadb-devel-5.5.56-2.el7.x86_64                                                 7/9 
  Verifying  : 1:mariadb-libs-5.5.56-2.el7.x86_64                                                  8/9 
  Verifying  : 1:mariadb-5.5.56-2.el7.x86_64                                                       9/9 

Installed:
  mysql-community-client.x86_64 0:5.6.38-2.el7       mysql-community-devel.x86_64 0:5.6.38-2.el7       
  mysql-community-libs.x86_64 0:5.6.38-2.el7         mysql-community-server.x86_64 0:5.6.38-2.el7      

Dependency Installed:
  libaio.x86_64 0:0.3.109-13.el7              mysql-community-common.x86_64 0:5.6.38-2.el7             

Replaced:
  mariadb.x86_64 1:5.5.56-2.el7 mariadb-devel.x86_64 1:5.5.56-2.el7 mariadb-libs.x86_64 1:5.5.56-2.el7

Complete!

安裝完成。

4.啟動MySQL

[root@izwz ~]# service mysqld start
Redirecting to /bin/systemctl start  mysqld.service

5.查看運行狀態

[root@izwz ~]# service mysqld status
Redirecting to /bin/systemctl status  mysqld.service
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2017-11-02 18:53:14 CST; 11min ago
 Main PID: 13242 (mysqld_safe)
   CGroup: /system.slice/mysqld.service
           ├─13242 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─13409 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mys...

Nov 02 18:53:12 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: which will also give you the option of removing the test
Nov 02 18:53:12 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: databases and anonymous user created by default.  This is
Nov 02 18:53:12 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: strongly recommended for production servers.
Nov 02 18:53:13 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: See the manual for more instructions.
Nov 02 18:53:13 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: Please report any problems at http://bugs.mysql.com/
Nov 02 18:53:13 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: The latest information about MySQL is available on the web at
Nov 02 18:53:13 izwz9f55c9f7l08ddn5qz7z mysql-systemd-start[13183]: http://www.mysql.com
Nov 02 18:53:13 izwz9f55c9f7l08ddn5qz7z mysqld_safe[13242]: 171102 18:53:13 mysqld_safe Logging to '/var/log/mysqld.log'.
Nov 02 18:53:13 izwz9f55c9f7l08ddn5qz7z mysqld_safe[13242]: 171102 18:53:13 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Nov 02 18:53:14 izwz9f55c9f7l08ddn5qz7z systemd[1]: Started MySQL Community Server.

到這應該沒有問題了,接下來就是怎麼配置的問題了。


配置mysql,設置密碼等

#配置mysql

[root@izwz ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y           #[設置root用戶密碼]  
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y          #[刪除匿名用戶]
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n    #[禁止root遠程登錄]
 ... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y  #[刪除test資料庫]
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y   #[刷新許可權]
 ... Success!




All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...
[root@izwz ~]# 

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 起因是想在微信小程式中獲取access_token。 之前資源只有一個阿裡雲虛擬主機和一個功能變數名稱,於是用C#後端寫了GET請求的介面,準備調用自己功能變數名稱下的介面獲取access_token 使用微信的wx.request介面 發現報錯,提示該功能變數名稱不在伺服器合法功能變數名稱中 於是去微信小程式的開發設置中的伺服器 ...
  • 1.1 修改配置文件 1.2 edusoho站點上線 第一個裡程碑:上傳解壓文件 [root@web01 tools]# tar xf edusoho-8.0.16.tar.gz 第二個裡程碑:移動站點文件到指定站點目錄 [root@web01 tools]# cd edusoho [root@we ...
  • 第1章 搭建VMware實戰環境 1.1 vmware主機配置-網路配置 1.1.1 虛擬主機添加網卡信息(5) a.右鍵虛擬主機→設置→添加虛擬網卡硬體設備 b.設置網路適配器類型→完成添加 1.1.2 虛擬主機配置網卡信息(6) a.編輯虛擬網路編輯器→修改虛擬網卡VMnet8配置→選擇NAT模 ...
  • 一、 簡介 1.1 介紹 ELK是三個開源工具組成,簡單解釋如下: Elasticsearch是個開源分散式搜索引擎,它的特點有:分散式,零配置,自動發現,索引自動分片,索引副本機制,restful風格介面,多數據源,自動搜索負載等。 Logstash是一個完全開源的工具,它可以對你的日誌進行收集、 ...
  • 為了更安全、方便的登錄Linux伺服器,可以取消密碼登錄,使用私鑰公鑰的方式來登錄,更方便也更安全。生成密鑰 藉助Xshell可以很方便的生成和管理私鑰,點擊工具菜單,選擇新建用戶密鑰生成嚮導: ...
  • 一、構成進程的要素 在linux系統中,進程主要具備以下要素: 1)有一個程式供其運行。這段程式不一定是進程所專有,可以與其他進程一起使用; 2)有起碼的“私有財產”,這就是進程專用的系統堆棧空間; 3)有“身份證”,也就是task_struct結構,也稱之為“進程式控制制塊”(PCB)。有了這個數據結 ...
  • 一、獲取全部cookie信息 這個比較方便,直接在nginx.conf文件中添加$http_cookie 第二步,在server 中的access.log 後加上 main 二、獲取單個cookie的值 有時候要是是覺得某個cookie很重要,需要單獨取出來,免得去一堆麻煩 首先,也是在nginx. ...
  • 新手必會用深黃色(8-15k)標記,老手必會深黃色+淺藍色(15-25K)標記 操作系統:Centos,Ubuntu,Redhat,suse,Freebsd 網站服務:nginx,apache,lighttpd,php,tomcat,resin數 據 庫 :MySQL,MariaDB,Postgre ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...