在centos中安裝mysql詳細步驟說明

来源:https://www.cnblogs.com/lxcy/archive/2017/12/29/8143252.html
-Advertisement-
Play Games

Last login: Sun Dec 24 04:55:59 2017 1、安裝依賴 [root@node001 ~]# yum install -y perlLoaded plugins: fastestmirrorLoading mirror speeds from cached hostfi ...


Last login: Sun Dec 24 04:55:59 2017

1、安裝依賴

[root@node001 ~]# yum install -y perl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Setting up Install Process
Package 4:perl-5.10.1-144.el6.x86_64 already installed and latest version
Nothing to do

2、 卸載舊版本的mysql及插件

[root@node001 ~]# rpm -qa | grep mysql
mysql-5.1.73-8.el6_8.x86_64
mysql-libs-5.1.73-8.el6_8.x86_64
mysql-server-5.1.73-8.el6_8.x86_64


[root@node001 ~]# rpm -e mysql-5.1.73-8.el6_8.x86_64 --nodeps

[root@node001 ~]# rpm -e mysql-libs-5.1.73-8.el6_8.x86_64 --nodeps

[root@node001 ~]# rpm -e mysql-server-5.1.73-8.el6_8.x86_64 --nodeps

(--nodeps:忽略其他依賴,直接卸載)

3、 安裝rpm(4個)

安裝包

[root@node001 ~]# tar zxvf mysql.tar.gz
MySQL-client-5.6.28-1.el6.x86_64.rpm
MySQL-devel-5.6.28-1.el6.x86_64.rpm
MySQL-server-5.6.28-1.el6.x86_64.rpm
numactl-2.0.9-2.el6.x86_64.rpm

 

[root@node001 ~]# rpm -ivh MySQL-client-5.6.28-1.el6.x86_64.rpm
warning: MySQL-client-5.6.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]


[root@node001 ~]# rpm -ivh MySQL-devel-5.6.28-1.el6.x86_64.rpm
warning: MySQL-devel-5.6.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-devel ########################################### [100%]


[root@node001 ~]# rpm -ivh numactl-2.0.9-2.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:numactl ########################################### [100%]

[root@node001 ~]# rpm -ivh MySQL-server-5.6.28-1.el6.x86_64.rpm
warning: MySQL-server-5.6.28-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
2017-12-24 05:39:08 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestam
p server option (see documentation for more details).2017-12-24 05:39:08 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 1287 ...
2017-12-24 05:39:08 1287 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-12-24 05:39:08 1287 [Note] InnoDB: The InnoDB memory heap is disabled
2017-12-24 05:39:08 1287 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-24 05:39:08 1287 [Note] InnoDB: Memory barrier is not used
2017-12-24 05:39:08 1287 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-12-24 05:39:08 1287 [Note] InnoDB: Using Linux native AIO
2017-12-24 05:39:08 1287 [Note] InnoDB: Using CPU crc32 instructions
2017-12-24 05:39:08 1287 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-12-24 05:39:08 1287 [Note] InnoDB: Completed initialization of buffer pool
2017-12-24 05:39:08 1287 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2017-12-24 05:39:08 1287 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2017-12-24 05:39:08 1287 [Note] InnoDB: Database physically writes the file full: wait...
2017-12-24 05:39:09 1287 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-12-24 05:39:10 1287 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-12-24 05:39:11 1287 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-12-24 05:39:11 1287 [Warning] InnoDB: New log files created, LSN=45781
2017-12-24 05:39:11 1287 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-12-24 05:39:11 1287 [Note] InnoDB: Doublewrite buffer created
2017-12-24 05:39:11 1287 [Note] InnoDB: 128 rollback segment(s) are active.
2017-12-24 05:39:11 1287 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-12-24 05:39:11 1287 [Note] InnoDB: Foreign key constraint system tables created
2017-12-24 05:39:11 1287 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-12-24 05:39:11 1287 [Note] InnoDB: Tablespace and datafile system tables created.
2017-12-24 05:39:11 1287 [Note] InnoDB: Waiting for purge to start
2017-12-24 05:39:11 1287 [Note] InnoDB: 5.6.28 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2017-12-24 05:39:11 1287 [Note] Binlog end
2017-12-24 05:39:11 1287 [Note] InnoDB: FTS optimize thread exiting.
2017-12-24 05:39:11 1287 [Note] InnoDB: Starting shutdown...
2017-12-24 05:39:13 1287 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2017-12-24 05:39:13 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestam
p server option (see documentation for more details).2017-12-24 05:39:13 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 1309 ...
2017-12-24 05:39:13 1309 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-12-24 05:39:13 1309 [Note] InnoDB: The InnoDB memory heap is disabled
2017-12-24 05:39:13 1309 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-24 05:39:13 1309 [Note] InnoDB: Memory barrier is not used
2017-12-24 05:39:13 1309 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-12-24 05:39:13 1309 [Note] InnoDB: Using Linux native AIO
2017-12-24 05:39:13 1309 [Note] InnoDB: Using CPU crc32 instructions
2017-12-24 05:39:13 1309 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-12-24 05:39:13 1309 [Note] InnoDB: Completed initialization of buffer pool
2017-12-24 05:39:13 1309 [Note] InnoDB: Highest supported file format is Barracuda.
2017-12-24 05:39:13 1309 [Note] InnoDB: 128 rollback segment(s) are active.
2017-12-24 05:39:13 1309 [Note] InnoDB: Waiting for purge to start
2017-12-24 05:39:13 1309 [Note] InnoDB: 5.6.28 started; log sequence number 1625977
2017-12-24 05:39:13 1309 [Note] Binlog end
2017-12-24 05:39:13 1309 [Note] InnoDB: FTS optimize thread exiting.
2017-12-24 05:39:13 1309 [Note] InnoDB: Starting shutdown...
2017-12-24 05:39:15 1309 [Note] InnoDB: Shutdown completed; log sequence number 1625987

 


A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

/usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

4、上傳mysql配置文件my.cnf

[root@node001 ~]# cd /etc

上傳文件

[root@node001 etc]# ls /etc/my.cnf
/etc/my.cnf

5、初始化

[root@node001 etc]# /usr/bin/mysql_install_db
Installing MySQL system tables...2017-12-24 05:41:57 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28-log) starting as process 1353 ...
2017-12-24 05:41:57 1353 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-12-24 05:41:57 1353 [Note] InnoDB: The InnoDB memory heap is disabled
2017-12-24 05:41:57 1353 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-24 05:41:57 1353 [Note] InnoDB: Memory barrier is not used
2017-12-24 05:41:57 1353 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-12-24 05:41:57 1353 [Note] InnoDB: Using Linux native AIO
2017-12-24 05:41:57 1353 [Note] InnoDB: Using CPU crc32 instructions
2017-12-24 05:41:57 1353 [Note] InnoDB: Initializing buffer pool, size = 64.0M
2017-12-24 05:41:57 1353 [Note] InnoDB: Completed initialization of buffer pool
2017-12-24 05:41:57 1353 [Note] InnoDB: Highest supported file format is Barracuda.
2017-12-24 05:41:57 1353 [Warning] InnoDB: Resizing redo log from 2*3072 to 3*2048 pages, LSN=1625987
2017-12-24 05:41:57 1353 [Warning] InnoDB: Starting to delete and rewrite log files.
2017-12-24 05:41:57 1353 [Note] InnoDB: Setting log file ./ib_logfile101 size to 32 MB
2017-12-24 05:41:58 1353 [Note] InnoDB: Setting log file ./ib_logfile1 size to 32 MB
2017-12-24 05:41:58 1353 [Note] InnoDB: Setting log file ./ib_logfile2 size to 32 MB
2017-12-24 05:41:58 1353 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-12-24 05:41:58 1353 [Warning] InnoDB: New log files created, LSN=1625987
2017-12-24 05:41:58 1353 [Note] InnoDB: 128 rollback segment(s) are active.
2017-12-24 05:41:58 1353 [Note] InnoDB: Waiting for purge to start
2017-12-24 05:41:58 1353 [Note] InnoDB: 5.6.28 started; log sequence number 1625987
2017-12-24 05:41:59 1353 [Note] Binlog end
2017-12-24 05:41:59 1353 [Note] InnoDB: FTS optimize thread exiting.
2017-12-24 05:41:59 1353 [Note] InnoDB: Starting shutdown...
2017-12-24 05:42:00 1353 [Note] InnoDB: Shutdown completed; log sequence number 1626134
OK

Filling help tables...2017-12-24 05:42:00 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28-log) starting as process 1376 ...
2017-12-24 05:42:00 1376 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-12-24 05:42:00 1376 [Note] InnoDB: The InnoDB memory heap is disabled
2017-12-24 05:42:00 1376 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-12-24 05:42:00 1376 [Note] InnoDB: Memory barrier is not used
2017-12-24 05:42:00 1376 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-12-24 05:42:00 1376 [Note] InnoDB: Using Linux native AIO
2017-12-24 05:42:00 1376 [Note] InnoDB: Using CPU crc32 instructions
2017-12-24 05:42:00 1376 [Note] InnoDB: Initializing buffer pool, size = 64.0M
2017-12-24 05:42:00 1376 [Note] InnoDB: Completed initialization of buffer pool
2017-12-24 05:42:00 1376 [Note] InnoDB: Highest supported file format is Barracuda.
2017-12-24 05:42:00 1376 [Note] InnoDB: 128 rollback segment(s) are active.
2017-12-24 05:42:00 1376 [Note] InnoDB: Waiting for purge to start
2017-12-24 05:42:00 1376 [Note] InnoDB: 5.6.28 started; log sequence number 1626134
2017-12-24 05:42:01 1376 [Note] Binlog end
2017-12-24 05:42:01 1376 [Note] InnoDB: FTS optimize thread exiting.
2017-12-24 05:42:01 1376 [Note] InnoDB: Starting shutdown...
2017-12-24 05:42:02 1376 [Note] InnoDB: Shutdown completed; log sequence number 1626144
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h 192.168.178.161 password 'new-password'

Alternatively you can run:

/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file /usr/my.cnf on the system.
Because this file might be in use, it was not replaced,
but was used in bootstrap (unless you used --defaults-file)
and when you later start the server.
The new default config file was created as /usr/my-new.cnf,
please compare it with your file and take the changes you need.

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

 

6、  啟動mysql

 

[root@node001 etc]# service mysql start
Starting MySQL....... SUCCESS!

 

 

7、重置密碼

查看初始化密碼

[root@node001 etc]# cat /root/.mysql_secret
# The random password set for the root user at Sun Dec 24 05:39:11 2017 (local time): DMBe85LznCxRo16N

 


[root@node001 etc]# mysql -u root -pDMBe85LznCxRo16N
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 2
Server version: 5.6.28-log

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> set password=password('mysql');
Query OK, 0 rows affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)

8、遠程授權

 

原因:預設遠程無法連接

 

授權命令:

 

mysql> grant all privileges on *.* to 'root'@'%' identified by 'mysql' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)


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

-Advertisement-
Play Games
更多相關文章
  • 本文主要是介紹Aop的一些概念,並結合實際編程,介紹了靜態織入和動態織入的幾種實現方式,並做了相應比較,從而讓讀者可以更好的選擇適合自己實際情況的技術方案。 ...
  • NPOI導出Excel及使用問題 因為最近公司質管部門提出了一個統計報表的需求:要求導出一個2016及2017年度深圳區域的所有供應商的費用成本計算——一個22列的Excel表,其中還包括多列的合併單元格;說實話,統計報表功能其實我還是很少涉及的,以前都是直接用DataTable+輸出流導出Exce ...
  • 回到目錄 單元測試大叔認為有幾下兩個必要的作用,也是為什麼要上單元測試的原因 目前添加了組件正確性的測試,在組件進行升級和優化之後,需要走一篇測試流程,以它的正確! 有條件的同學,可以在自己的源代碼管理上添加pipeline,在你的新項目修改遷入後,讓它自動進行測試,這樣也可以保證項目的質量! 這應 ...
  • 內插字元串($) 實際上是C# 6.0對string.Format的改進,將字元串文本標識為內插字元串($)根據微軟的例子來看: 相當於原先的string.Format這種必須使用占位符,極容易出錯: 而使用$則不容易出現錯誤,可以這樣寫: 新增語法糖:(?.) 這也是C#6.0的語法,這叫Null ...
  • <!--Ad Injection:top--> <!--Ad Injection:random--> Xmind Pro 8是一款用於思維導圖和頭腦風暴軟體的精彩軟體。這個軟體是非常有用的應用程式,提供簡單的方法來繪製您的想法在圖形和組織任務。Xmind Pro 8許可證密鑰是非常簡單的軟體,它能夠 ...
  • 最近在網上看到很多ES集群的搭建方法,本人在這人使用Elasticsearch5.0.1版本,介紹如何搭建es集群並安裝head插件和其他插件安裝方法。 一、搭建環境(2台Centos7系統伺服器) 所需軟體 基礎環境JAVA 測試環境關閉防火牆和selinux 配置主機名和hosts文件 創建用戶 ...
  • 操作系統版本:CentOS Linux release 7.2.1511 (Core) SSH版本:OpenSSH_6.6.1p1, OpenSSL 1.0.1e-fips 1.打開Xshell工具,點擊“工具”,選擇“新建用戶密鑰生成嚮導”,如圖所示: 2.選擇密鑰類型為“RSA”,密鑰長度為“1 ...
  • 新建文本文檔,更改尾碼為“.bat”,寫入以下代碼: netsh interface ip set address name="本地連接" source=static 192.168.1.110 255.255.255.0 192.168.1.1 1 name是網卡的名字。 在WIN10中測試,要右 ...
一周排行
    -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.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...