1. 程式人生 > >Linux環境安裝Mysql資料庫的三種方式之一:二進位制包方式安裝

Linux環境安裝Mysql資料庫的三種方式之一:二進位制包方式安裝

本文是在CentOS7系統平臺下安裝Mysql5.6.26版本資料庫的操作說明,如有錯誤,請指正。

系統平臺:CentOS-7-x86_64  

資料庫版本:mysql-5.6.26

本次演示的Mysql安裝包版本:mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz

1、新增mysql使用者組及mysql使用者

[[email protected] ~]# groupadd mysql

[[email protected] ~]# useradd -r -g mysql mysql

2、將二進位制檔案解壓到指定的安裝目錄:/usr/local/mysql

到mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz包的目錄下,解壓到/usr/local目錄下:

[[email protected] tmp]# tar zxvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz -C /usr/local/

到/usr/local/目錄中,重新命名解壓出來的目錄名,改為mysql:

[[email protected]alhost tmp]# cd /usr/local/

[[email protected] local]# mv mysql-5.6.26-linux-glibc2.5-x86_64 mysql

檢視此目錄下檔案:

[[email protected] local]# cd mysql/

[[email protected] mysql]# ls
bin     data  include         lib mysql-test  scripts  sql-bench
COPYING docs  INSTALL-BINARY  man README      share    support-files

注:/usr/local/mysql/下的目錄結構

Directory

Contents of Directory

bin

Client programs and the mysqld

server

data

Log files, databases

docs

Manual in Info format

man

Unix manual pages

include

Include (header) files

lib

Libraries

scripts

mysql_install_db

share

Miscellaneous support files, including error messages, sample configuration files, SQL for database installation

sql-bench

Benchmarks

3、建立mysql資料存放的目錄:/data/mysql

[[email protected] mysql]# mkdir -p /data/mysql

4、更改所屬的組和使用者

[[email protected] mysql]# chown -R mysql:mysql /usr/local/mysql/

[[email protected] mysql]# chown -R mysql:mysql /data/mysql/

5、初始化mysql

註釋:以mysql使用者執行mysql_install_db指令碼,基本目錄為:/usr/local/mysql/,資料檔案目錄為:/data/mysql/

[[email protected] mysql]# pwd
/usr/local/mysql

[[email protected] mysql]#./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/

Installing MySQL system tables...2015-08-3114:24:16 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.Please use --explicit_defaults_for_timestamp server option (see documentationfor more details).
2015-08-31 14:24:16 0 [Note]/usr/local/mysql//bin/mysqld (mysqld 5.6.26) starting as process 36847 ...
2015-08-31 14:24:17 36847 [Note] InnoDB:Using atomics to ref count buffer pool pages
2015-08-31 14:24:17 36847 [Note] InnoDB:The InnoDB memory heap is disabled
2015-08-31 14:24:17 36847 [Note] InnoDB:Mutexes and rw_locks use GCC atomic builtins
2015-08-31 14:24:17 36847 [Note] InnoDB:Memory barrier is not used
2015-08-31 14:24:17 36847 [Note] InnoDB:Compressed tables use zlib 1.2.3
2015-08-31 14:24:17 36847 [Note] InnoDB:Using Linux native AIO
2015-08-31 14:24:17 36847 [Note] InnoDB:Using CPU crc32 instructions
2015-08-31 14:24:17 36847 [Note] InnoDB:Initializing buffer pool, size = 128.0M
2015-08-31 14:24:17 36847 [Note] InnoDB:Completed initialization of buffer pool
2015-08-31 14:24:17 36847 [Note] InnoDB:The first specified data file ./ibdata1 did not exist: a new database to becreated!
2015-08-31 14:24:17 36847 [Note] InnoDB:Setting file ./ibdata1 size to 12 MB
2015-08-31 14:24:17 36847 [Note] InnoDB:Database physically writes the file full: wait...
2015-08-31 14:24:17 36847 [Note] InnoDB:Setting log file ./ib_logfile101 size to 48 MB
2015-08-31 14:24:18 36847 [Note] InnoDB:Setting log file ./ib_logfile1 size to 48 MB
2015-08-31 14:24:18 36847 [Note] InnoDB:Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-08-31 14:24:18 36847 [Warning] InnoDB:New log files created, LSN=45781
2015-08-31 14:24:18 36847 [Note] InnoDB:Doublewrite buffer not found: creating new
2015-08-31 14:24:18 36847 [Note] InnoDB:Doublewrite buffer created
2015-08-31 14:24:18 36847 [Note] InnoDB:128 rollback segment(s) are active.
2015-08-31 14:24:18 36847 [Warning] InnoDB:Creating foreign key constraint system tables.
2015-08-31 14:24:18 36847 [Note] InnoDB:Foreign key constraint system tables created
2015-08-31 14:24:18 36847 [Note] InnoDB:Creating tablespace and datafile system tables.
2015-08-31 14:24:18 36847 [Note] InnoDB:Tablespace and datafile system tables created.
2015-08-31 14:24:18 36847 [Note] InnoDB:Waiting for purge to start
2015-08-31 14:24:18 36847 [Note] InnoDB:5.6.26 started; log sequence number 0
2015-08-31 14:24:19 36847 [Note] Binlog end
2015-08-31 14:24:19 36847 [Note] InnoDB:FTS optimize thread exiting.
2015-08-31 14:24:19 36847 [Note] InnoDB:Starting shutdown...
2015-08-31 14:24:20 36847 [Note] InnoDB:Shutdown completed; log sequence number 1625977
OK

Filling help tables...2015-08-31 14:24:20 0[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use--explicit_defaults_for_timestamp server option (see documentation for moredetails).
2015-08-31 14:24:20 0 [Note]/usr/local/mysql//bin/mysqld (mysqld 5.6.26) starting as process 36869 ...
2015-08-31 14:24:20 36869 [Note] InnoDB:Using atomics to ref count buffer pool pages
2015-08-31 14:24:20 36869 [Note] InnoDB:The InnoDB memory heap is disabled
2015-08-31 14:24:20 36869 [Note] InnoDB:Mutexes and rw_locks use GCC atomic builtins
2015-08-31 14:24:20 36869 [Note] InnoDB:Memory barrier is not used
2015-08-31 14:24:20 36869 [Note] InnoDB:Compressed tables use zlib 1.2.3
2015-08-31 14:24:20 36869 [Note] InnoDB:Using Linux native AIO
2015-08-31 14:24:20 36869 [Note] InnoDB:Using CPU crc32 instructions
2015-08-31 14:24:20 36869 [Note] InnoDB:Initializing buffer pool, size = 128.0M
2015-08-31 14:24:20 36869 [Note] InnoDB:Completed initialization of buffer pool
2015-08-31 14:24:20 36869 [Note] InnoDB:Highest supported file format is Barracuda.
2015-08-31 14:24:21 36869 [Note] InnoDB:128 rollback segment(s) are active.
2015-08-31 14:24:21 36869 [Note] InnoDB:Waiting for purge to start
2015-08-31 14:24:21 36869 [Note] InnoDB:5.6.26 started; log sequence number 1625977
2015-08-31 14:24:21 36869 [Note] Binlog end
2015-08-31 14:24:21 36869 [Note] InnoDB:FTS optimize thread exiting.
2015-08-31 14:24:21 36869 [Note] InnoDB:Starting shutdown...
2015-08-31 14:24:22 36869 [Note] InnoDB:Shutdown completed; log sequence number 1625987
OK

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

PLEASE REMEMBER TO SET A PASSWORD FOR THEMySQL root USER !

To do so, start the server, then issue thefollowing commands:

 /usr/local/mysql//bin/mysqladmin -u root password 'new-password'

 /usr/local/mysql//bin/mysqladmin -u root -h localhost.localdomainpassword 'new-password'

Alternatively you can run:

 /usr/local/mysql//bin/mysql_secure_installation

which will also give you the option ofremoving the test

databases and anonymous user created bydefault.  This is

strongly recommended for productionservers.

See the manual for more instructions.

You can start the MySQL daemon with:

  cd. ; /usr/local/mysql//bin/mysqld_safe &

You can test the MySQL daemon withmysql-test-run.pl

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

Please report any problems athttp://bugs.mysql.com/

The latest information about MySQL isavailable on the web at

 http://www.mysql.com

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

New default config file was created as/usr/local/mysql//my.cnf and
will be used by default by the server whenyou start it.
You may edit this file to change serversettings

WARNING: Default config file /etc/my.cnfexists on the system
This file will be read by default by theMySQL server
If you do not want to use this, eitherremove it, or use the
--defaults-file argument to mysqld_safewhen starting the server

注:本次啟動有一個報錯如下:

FATAL ERROR: please install the followingPerl modules before executing ./scripts/mysql_install_db:

Data::Dumper

解決方案:

[[email protected] mysql]# yum install -yperl-Module-Install.noarch

6、修改my.cnf配置檔案

複製/usr/local/mysql/support-files/my-default.conf 檔案到/etc/ 目錄下,覆蓋原有的配置檔案mysql/my.cnf:

[[email protected] mysql]# cp support-files/my-default.cnf  /etc/my.cnf

修改/etc/my.cnf 檔案,指定datadir、basedir 路徑,同時開啟3306埠:

basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306

7、複製mysql 啟動指令碼mysql.server 到/etc/init.d/mysqld

[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld

8、修改啟動指令碼的許可權為755,賦予執行許可權

[[email protected] mysql]# chmod 755 /etc/init.d/mysqld

9、通過chkconfig命令將mysqld服務加入到自啟動服務項中:

[[email protected] init.d]# pwd
/etc/init.d

[[email protected] init.d]# chkconfig --add mysqld

檢查是否加入到自動啟動

[[email protected] init.d]# chkconfig --list mysqld
mysqld          0:off   1:off  2:on    3:on    4:on   5:on    6:off

10、啟動mysql服務:

[[email protected] mysql]# service mysqld start
Starting MySQL... SUCCESS!

11、進入mysql

[[email protected] mysql]#/usr/local/mysql/bin/mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.26 MySQL CommunityServer (GPL)

Copyright (c) 2000, 2015, Oracle and/or itsaffiliates. All rights reserved.

Oracle is a registered trademark of OracleCorporation and/or its
affiliates. Other names may be trademarksof their respective
owners.

Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.

mysql>

注:在/etc/profile中加入以下環境變數,可以用mysql代替/usr/local/mysql/bin/mysql啟動

MYSQL_HOME=/usr/local/mysql

exportPATH=$PATH:$MYSQL_HOME/bin

設定後需要重新載入一下:

[[email protected] mysql]# source /etc/profile

再次進入mysql

[[email protected] mysql]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.26 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> 


相關推薦

Linux環境安裝Mysql資料庫方式之一二進位制方式安裝

本文是在CentOS7系統平臺下安裝Mysql5.6.26版本資料庫的操作說明,如有錯誤,請指正。 系統平臺:CentOS-7-x86_64   資料庫版本:mysql-5.6.26 本次演示的Mysql安裝包版本:mysql-5.6.26-linux-glibc2

linux環境變數設定的方法

login shell 和 no-login shell“login shell” 代表使用者登入, 比如使用 “su -“ 命令, 或者用 ssh 連線到某一個伺服器上, 都會使用該使用者預設 shell 啟動 login shell 模式.該模式下的 shell 會去自動

Linux環境mysql資料庫定時備份

作為web後端開發,一直都是在windows系統上對mysql進行增刪改查的工作,對於如何備份以及在linux環境下如何定時備份一直都沒有深入的去了解過;這次正好藉著專案需求,研究一下。 1、mysql資料庫的備份命令:/usr/bin/mysqldump -uroot -

LINUX環境併發伺服器的實現模型

伺服器設計技術有很多,按使用的協議來分有TCP伺服器和UDP伺服器。按處理方式來分有迴圈伺服器和併發伺服器。 1  迴圈伺服器與併發伺服器模型 在網路程式裡面,一般來說都是許多客戶對應一個伺服器,為了處理客戶的請求,對服務端的程式就提出了特殊的要求。 目前最常用的伺服器模型

MySQL資料庫日誌分析

目錄 1 MySQL工具mysqlbinlog mysqlbinlog工具的作用是解析mysql的二進位制binlog日誌內容,把二進位制日誌解析成可以在MySQL資料庫裡執行的SQL語句。 [[email protected] ~]#

自學Linux Shell9.3-基於Red Hat系統工具存在兩方式之一原始碼

9.3-基於Red Hat系統工具包存在兩種方式之一:原始碼包 本節主要介紹基於Red Had的系統(測試系統centos) 1. 工具包存在兩種方式:RPM包與原始碼包 1.1.RPM包與原始碼包區別 安裝之前的區別:概念上的區別    原始碼包是開源的,比RPM包安裝更自由,但是它安裝更慢,更容易報錯

詳解資料庫刪除方法 delete drop truncate

Delete Delete :刪除資料表中的行(可以刪除某一行,也可以在不刪除資料表的情況下刪除所有行)。 刪除某一行:Delete from 資料表名稱 where 列名稱=值; 刪除所有行:Delete * from 資料表名稱 Drop Drop :刪除

Linux環境安裝Mysql資料庫(手工+自動兩 詳細版)

1、新增mysql使用者組以及使用者 groupadd mysql useradd -g mysql mysql 2、解壓mysql 並制定安裝目錄 cd /root/software/

***在Linux環境mysql的root密碼忘記解決方法()-推薦第

href containe 完全 mys init.d 操作 root ubunt upd MySQL密碼的恢復方法之一 1.首先確認服務器出於安全的狀態,也就是沒有人能夠任意地連接MySQL數據庫。 因為在重新設置MySQL的root密碼的期間,MySQL數據庫完全出於沒

Linux安裝軟體的方式--rpm、yum、原始碼

說明:此文首發於本人原創公眾號【媛測】中,如有轉載,請著明出處! 在windows系統下安裝軟體很簡單,下載軟體包後雙擊.exe檔案,點選下一步即可。然而在linux安裝軟體就沒那麼容易了,不同的Linux發行版有所差異,下面以centos7系統為例說明,如何在linux下安裝軟體

linux安裝軟體的方式

原文:https://www.cnblogs.com/heiye123/articles/7291326.html 目錄 【rpm工具】 【yum工具】 【安裝原始碼包】   正文       &nbs

linux環境安裝mysql資料庫

1.檢視linux版本:file /sbin/init 或者 file /bin/ls 2.檢視系統是否已經安裝了mysql的其他版本: ps:yum與rpm等改天系統學一下 [root@leo usr]#rpm -qa|grep mysql mysql-libs-5.1.52-1.

deepin(linux)環境安裝mysql資料庫(新手入門)

環境:deepin15.5 1.開啟終端,輸入命令:sudo apt-get update   更新軟體列表 2.輸入命令:sudo apt-get install mysql-server     安裝MySQL資料庫程式 中間會彈出設定root使用者密碼的輸入框,輸

Linux系統安裝rpm方式安裝mysql資料庫

一:官網下載RPM包登陸官網地址下載https://dev.mysql.com/downloads/mysql/,並上傳至伺服器,可以通過xftp或者filezilla上傳。二:安裝前的準備工作一般可以將檔案上傳至/usr/目錄下新建一個mysql目錄存放tar包,然後通過t

Linux 環境部署記錄() - Jenkins安裝與配置

版本 接下來 clas title col size pre 瀏覽器 jdk Jenkins安裝 為了兼容生產環境的jdk1.7版本,從官網得知,Jenkins必須是1.6之前的版本,因此下載jenkins-1.596.3-1.1.noarch.rpm到本地進行安裝: #移

Linux安裝MySQL資料庫mysql-5.7.11

Linux下安裝MySQL資料庫(壓縮包方式安裝) https://www.cnblogs.com/xiaotao726/p/6562265.html PS:9、建立In ln -s /usr/local/mysql/ /usr/bin/ 連線資料庫時會顯示:[[email protecte

Linux下建立程序的方式及特點

在Linux中主要提供了fork、vfork、clone三個程序建立方法。  在linux原始碼中這三個呼叫的執行過程是執行fork(),vfork(),clone()時,通過一個系統呼叫表對映到sys_fork(),sys_vfork(),sys_clone(),再在這三個函式中去呼叫d

ecs雲伺服器linux系統安裝mysql資料庫

Linux64安裝mysql資料庫流程簡介 Mysql官網上下載mysql資料庫壓縮包到本地。 通過xftp上傳壓縮包到linux系統的usr/local資料夾下。 在Linux系統終端執行解壓指令 tar -zxvf (壓縮包名字) 出現以下畫面表示解壓成功 新

Linux 安裝 mysql 資料庫

1. 克隆虛擬機器   2. 上傳安裝檔案   1.上傳檔案   2.解壓檔案   tar -xvf 檔案   3. 安裝資料庫 安裝順序: 1.debuginfo 2.shared 3.client 4.server 1. rpm -ivh

linux centos下mysql資料庫的主從複製環境搭建

有兩臺MySQL資料庫伺服器Master和slave,Master為主伺服器,slave為從伺服器,初始狀態時,Master和slave中的資料資訊相同,當Master中的資料發生變化時,slave也跟著發生相應的變化,使得master和slave的資料資訊同步,達到備份的目的。 原理圖如下: