Centos 下 mysql 安裝過程

来源:https://www.cnblogs.com/idotest/archive/2019/04/03/10651421.html
-Advertisement-
Play Games

1. 檢查系統自帶的Mysql,並卸載自帶的版本 2. 卸載系統自帶的mysql及其依賴 3. 給CentOS添加rpm源,並且選擇較新的源 1)下載rpm包 2)安裝本地mysql源 3)驗證是否安裝成功 4)修改預設版本為5.7 註:如下是截取的老徐之前文章 -》原文 http://istest ...



1. 檢查系統自帶的Mysql,並卸載自帶的版本

 

 

[root@iZ2366ycl7sZ config]# yum list installed |grep mysql
mysql.x86_64            5.1.73-5.el6_6  @base                                   
mysql-libs.x86_64       5.1.73-5.el6_6  @base                                   
php56w-mysql.x86_64     5.6.40-1.w6     @webtatic     

 

 

 

2. 卸載系統自帶的mysql及其依賴 

 

[root@iZ2366ycl7sZ config]# yum -y remove mysql-libs.x86_64
Loaded plugins: security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.73-5.el6_6 will be erased
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: php56w-mysql-5.6.40-1.w6.x86_64
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-6.el6_5.x86_64
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: mysql-5.1.73-5.el6_6.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: php56w-mysql-5.6.40-1.w6.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-6.el6_5.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: mysql-5.1.73-5.el6_6.x86_64
--> Processing Dependency: libmysqlclient_r.so.16()(64bit) for package: php56w-mysql-5.6.40-1.w6.x86_64
--> Processing Dependency: libmysqlclient_r.so.16()(64bit) for package: mysql-5.1.73-5.el6_6.x86_64
--> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package: php56w-mysql-5.6.40-1.w6.x86_64
--> Processing Dependency: libmysqlclient_r.so.16(libmysqlclient_16)(64bit) for package: mysql-5.1.73-5.el6_6.x86_64
--> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-6.el6_5.x86_64
--> Processing Dependency: mysql-libs = 5.1.73-5.el6_6 for package: mysql-5.1.73-5.el6_6.x86_64
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-5.el6_6 will be erased
---> Package php56w-mysql.x86_64 0:5.6.40-1.w6 will be erased
---> Package postfix.x86_64 2:2.6.6-6.el6_5 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================
 Package                          Arch                       Version                                Repository                     Size
========================================================================================================================================
Removing:
 mysql-libs                       x86_64                     5.1.73-5.el6_6                         @base                         4.0 M
Removing for dependencies:
 mysql                            x86_64                     5.1.73-5.el6_6                         @base                         2.4 M
 php56w-mysql                     x86_64                     5.6.40-1.w6                            @webtatic                     457 k
 postfix                          x86_64                     2:2.6.6-6.el6_5                        @updates                      9.7 M

Transaction Summary
========================================================================================================================================
Remove        4 Package(s)

Installed size: 17 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : php56w-mysql-5.6.40-1.w6.x86_64                                                                                      1/4 
  Erasing    : 2:postfix-2.6.6-6.el6_5.x86_64                                                                                       2/4 
  Erasing    : mysql-5.1.73-5.el6_6.x86_64                                                                                          3/4 
  Erasing    : mysql-libs-5.1.73-5.el6_6.x86_64                                                                                     4/4 
  Verifying  : mysql-libs-5.1.73-5.el6_6.x86_64                                                                                     1/4 
  Verifying  : php56w-mysql-5.6.40-1.w6.x86_64                                                                                      2/4 
  Verifying  : mysql-5.1.73-5.el6_6.x86_64                                                                                          3/4 
  Verifying  : 2:postfix-2.6.6-6.el6_5.x86_64                                                                                       4/4 

Removed:
  mysql-libs.x86_64 0:5.1.73-5.el6_6                                                                                                    

Dependency Removed:
  mysql.x86_64 0:5.1.73-5.el6_6              php56w-mysql.x86_64 0:5.6.40-1.w6              postfix.x86_64 2:2.6.6-6.el6_5             

Complete!

 

3. 給CentOS添加rpm源,並且選擇較新的源

 

1)下載rpm包

 

[root@iZ2366ycl7sZ software]# wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm --no-check-certificate
--2019-03-29 14:45:46--  http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
Resolving dev.mysql.com... 137.254.60.11
Connecting to dev.mysql.com|137.254.60.11|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm [following]
--2019-03-29 14:45:46--  https://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
Connecting to dev.mysql.com|137.254.60.11|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://repo.mysql.com//mysql-community-release-el6-5.noarch.rpm [following]
--2019-03-29 14:45:48--  https://repo.mysql.com//mysql-community-release-el6-5.noarch.rpm
Resolving repo.mysql.com... 104.127.195.16
Connecting to repo.mysql.com|104.127.195.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5824 (5.7K) [application/x-redhat-package-manager]
Saving to: “mysql-community-release-el6-5.noarch.rpm”

100%[==============================================================================================>] 5,824       --.-K/s   in 0s      

2019-03-29 14:45:48 (506 MB/s) - “mysql-community-release-el6-5.noarch.rpm” saved [5824/5824]

 

2)安裝本地mysql源

 

[root@iZ2366ycl7sZ software]# yum localinstall mysql-community-release-el6-5.noarch.rpm
Loaded plugins: security
Setting up Local Package Process
Examining mysql-community-release-el6-5.noarch.rpm: mysql-community-release-el6-5.noarch
Marking mysql-community-release-el6-5.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-release.noarch 0:el6-5 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================
 Package                              Arch                Version              Repository                                          Size
========================================================================================================================================
Installing:
 mysql-community-release              noarch              el6-5                /mysql-community-release-el6-5.noarch              4.3 k

Transaction Summary
========================================================================================================================================
Install       1 Package(s)

Total size: 4.3 k
Installed size: 4.3 k
Is this ok [y/N]: y
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-community-release-el6-5.noarch                                                                                 1/1 
  Verifying  : mysql-community-release-el6-5.noarch                                                                                 1/1 

Installed:
  mysql-community-release.noarch 0:el6-5                                                                                                

Complete!

 

3)驗證是否安裝成功

 

[root@iZ2366ycl7sZ software]# yum repolist all | grep mysql
mysql-connectors-community        MySQL Connectors Community     enabled:     83
mysql-connectors-community-source MySQL Connectors Community - S disabled
mysql-tools-community             MySQL Tools Community          enabled:     74
mysql-tools-community-source      MySQL Tools Community - Source disabled
mysql55-community                 MySQL 5.5 Community Server     disabled
mysql55-community-source          MySQL 5.5 Community Server - S disabled
mysql56-community                 MySQL 5.6 Community Server     enabled:    493
mysql56-community-source          MySQL 5.6 Community Server - S disabled
mysql57-community-dmr             MySQL 5.7 Community Server Dev disabled
mysql57-community-dmr-source      MySQL 5.7 Community Server Dev disabled

 

4)修改預設版本為5.7

 

 

註:如下是截取的老徐之前文章 -》原文 http://istester.com/huanjing/134.html

 


如上,預設是5.6版本可用,如果想安裝5.7怎麼操作?

有如下兩個方法:

 

方法一:

執行:

yum-config-manager --disable mysql56-community

yum-config-manager --enable mysql57-community-dmr

 

如上操作,是把5.6禁用,把5.7啟用

此法,會有異常情況:

如果執行命令出現如下錯誤:

-bash: yum-config-manager: command not found

可用執行如下命令解決,然後繼續上面的操作命令:

yum -y install yum-utils

 

註意:如上操作可能有一部分同學的會出現一些問題;好處是操作簡單,兩個命令搞定~

如果有問題,底部給老徐留言~

 

 

方法二:

直接編輯配置文件,簡單、直接,基本不會出現錯誤~

vi /etc/yum.repos.d/mysql-community.repo 

把5.6的enabled=0

把5.7的enabled=1

然後保存就ok

 

# Enable to use MySQL 5.5

[mysql55-community]

name=MySQL 5.5 Community Server

baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/

enabled=0

gpgcheck=1

gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

 

# Enable to use MySQL 5.6

[mysql56-community]

name=MySQL 5.6 Community Server

baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/

enabled=0

gpgcheck=1

gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

 

# Note: MySQL 5.7 is currently in development. For use at your own risk.

# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/

[mysql57-community-dmr]

name=MySQL 5.7 Community Server Development Milestone Release

baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/

enabled=1

gpgcheck=1

gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql


如上,顏色標記處 。

此時,再執行:

yum repolist all | grep mysql

就可以看到,5.7是啟用的

 

 

[root@localhost webserver]# yum repolist all | grep mysql

mysql-connectors-community        MySQL Connectors Community         啟用:    21

mysql-connectors-community-source MySQL Connectors Community - Sourc 禁用

mysql-tools-community             MySQL Tools Community              啟用:    38

mysql-tools-community-source      MySQL Tools Community - Source     禁用

mysql55-community                 MySQL 5.5 Community Server         禁用

mysql55-community-source          MySQL 5.5 Community Server - Sourc 禁用

mysql56-community                 MySQL 5.6 Community Server         禁用

mysql56-community-source          MySQL 5.6 Community Server - Sourc 禁用

mysql57-community-dmr             MySQL 5.7 Community Server Develop 啟用:   130

mysql57-community-dmr-source      MySQL 5.7 Community Server Develop 禁用


如上 。

OK,至此,基礎準備工作完成 。

 

 

 

4. 安裝mysql

執行如下命令:

yum install mysql-community-server

 

[root@iZ2366ycl7sZ software]# yum install mysql-community-server
Loaded plugins: security
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.25-1.el6 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.25-1.el6 for package: mysql-community-server-5.7.25-1.el6.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.25-1.el6.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.25-1.el6 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.25-1.el6.x86_64
---> Package mysql-community-common.x86_64 0:5.7.25-1.el6 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.25-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================
 Package                                Arch                   Version                      Repository                             Size
========================================================================================================================================
Installing:
 mysql-community-server                 x86_64                 5.7.25-1.el6                 mysql57-community-dmr                 153 M
Installing for dependencies:
 mysql-community-client                 x86_64                 5.7.25-1.el6                 mysql57-community-dmr                  23 M
 mysql-community-common                 x86_64                 5.7.25-1.el6                 mysql57-community-dmr                 332 k
 mysql-community-libs                   x86_64                 5.7.25-1.el6                 mysql57-community-dmr                 2.1 M

Transaction Summary
========================================================================================================================================
Install       4 Package(s)

Total download size: 178 M
Installed size: 887 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): mysql-community-client-5.7.25-1.el6.x86_64.rpm                                                            |  23 MB     00:01     
(2/4): mysql-community-common-5.7.25-1.el6.x86_64.rpm                                                            | 332 kB     00:00     
(3/4): mysql-community-libs-5.7.25-1.el6.x86_64.rpm                                                              | 2.1 MB     00:00     
(4/4): mysql-community-server-5.7.25-1.el6.x86_64.rpm                                                            | 153 MB     00:04     
----------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                    32 MB/s | 178 MB     00:05     
warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Retrieving key from file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
 Userid : MySQL Release Engineering <[email protected]>
 Package: mysql-community-release-el6-5.noarch (@/mysql-community-release-el6-5.noarch)
 From   : file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-community-common-5.7.25-1.el6.x86_64                                                                           1/4 
  Installing : mysql-community-libs-5.7.25-1.el6.x86_64                                                                             2/4 
  Installing : mysql-community-client-5.7.25-1.el6.x86_64                                                                           3/4 
  Installing : mysql-community-server-5.7.25-1.el6.x86_64                                                                           4/4 
  Verifying  : mysql-community-libs-5.7.25-1.el6.x86_64                                                                             1/4 
  Verifying  : mysql-community-common-5.7.25-1.el6.x86_64                                                                           2/4 
  Verifying  : mysql-community-client-5.7.25-1.el6.x86_64                                                                           3/4 
  Verifying  : mysql-community-server-5.7.25-1.el6.x86_64                                                                           4/4 

Installed:
  mysql-community-server.x86_64 0:5.7.25-1.el6                                                                                          

Dependency Installed:
  mysql-community-client.x86_64 0:5.7.25-1.el6 mysql-community-common.x86_64 0:5.7.25-1.el6 mysql-community-libs.x86_64 0:5.7.25-1.el6

Complete!

 

 

5. 啟動mysql

 

 

[root@iZ2366ycl7sZ software]# service mysqld start
Initializing MySQL database:                               [  OK  ]
Starting mysqld:                                           [  OK  ]

 

6. 查看mysql服務狀態

 

 

[root@iZ2366ycl7sZ software]# service mysqld status
mysqld (pid  7036) is running...

 

7. 查看mysql 初始密碼

mysql5.7之後初始密碼不再預設為空

 

[root@iZ2366ycl7sZ software]# grep 'temporary password' /var/log/mysqld.log 
2019-03-29T07:09:36.375706Z 1 [Note] A temporary password is generated for root@localhost: xo%LBtyoo2MV

其中,最後的xo%LBtyoo2MV 就是密碼

 

 

8. 命令行登錄mysql ,並修改密碼

 

登錄之後 第一步必須先修改密碼,

否則其他操作都執行不了。

mysql -u root -p

 

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

 

9. 修改密碼的方法:

alter user root@localhost identified by 'passwd';

# 'passwd' 里,填寫你的新密碼 。

新修改的密碼中 必須包含 大小寫字母數字及符號

 

 

End 。

 

完整的mysql相關操作,見之前的文章 http://istester.com/huanjing/134.html

 

補充,

搭建博客的文章文章 -》 http://istester.com/bushu/254.html

 


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

-Advertisement-
Play Games
更多相關文章
  • 如何使用C# 操作存儲過程,執行sql語句? 閑話不多說,直接上代碼: /// <summary> /// Sql通用類 /// </summary> public class SqlHelper { 首先配置連接字元串 public static string connStr = Configur ...
  • 在Sqlserver資料庫中,如果查詢表中含有自增長Id列,一般會採用select Top的方式來數據的分頁操作。而實際上很多數據表設計的時候,不一定含有自增長Id列,那麼資料庫沒有Id自增列的時候要對數據分頁怎麼辦呢,此時則需要使用ROW_NUMBER()函數來對數據分頁,ROW_NUMBER() ...
  • 壓縮(makecab): 其中: /f 指定的c;\list.txt(路徑自定義)是你要進行壓縮的文件的列表,不能包含文件夾,在根文件下的子文件夾中不能包含相同文件名的文件,因為cab壓縮後不保留文件結構,否則會報錯(ERROR: Duplicate file name)。 list.txt 可以使 ...
  • Linux常見系統故障 1.修複MBR扇區故障 2.修複GRUB引導故障 3./etc/inittab文件丟失 4.遺忘root用戶密碼 5.修複文件系統 6.磁碟資源耗盡故障 一、修複MBR扇區故障 1.關機添加一塊硬碟,開機查看硬碟設備分區列表,是否存在/dev/sdb設備信息 2.對新硬碟分區 ...
  • 使用Expand命令行可以在電腦沒有安裝Windows操作系統的情況下應用批處理文件和腳本: 雖然有多個基於Windows的工具可以壓縮和解壓縮文件(包括WinZip和WinRAR),但是必須有一個可以工作的Windows操作系統才能使用它們。 Expand工具用來壓縮的Wndows CAB文件中 ...
  • 我在使用SDL2的時候,遇到undefined reference to `SDL_Init'的問題,只要使用SDL2相關的函數,就會報函數未定義。後來百度到一篇文章https://blog.csdn.net/hank12580/article/details/45949995,經過測試可以使用,原 ...
  • 我在使用SDL2的時候遇到始終找不到頭文件的問題,到處百度然後我嘗試使用#include<SDL2/SDL.h>編譯通過了,那麼我很顯然我之前設置的環境變數應該是沒有生效的,後面在返回來研究下為啥沒有生效,linux的基礎知識太薄弱了,應該好好補習一下。 ...
  • 今天打算學習littlev GUI,使用Ubuntu來實現模擬,然後在安裝SDL2的時候,始終因為依賴關係導致安裝失敗,我嘗試手動去安裝那些有依賴關係的包發現根本不可行,然後我百度上也沒有找到合適的法子,但是看有的網友說是因為源的問題,我思考了下覺得這個說法有一定道理,然後我嘗試切換源,我測試了16 ...
一周排行
    -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.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...