采用二進制包安裝mysql

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

系統平臺:CentOS-7-x86_64   

數據庫版本:mysql-5.6.26

 

Mysql鏡像文件下載地址:http://dev.mysql.com/downloads/mirrors.html

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

1、添加mysql用戶組及mysql用戶

[root@localhost ~]# groupadd mysql

[root@localhost ~]# useradd -r -g mysql mysql

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

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

[root@localhost tmp]# tar zxvf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz -C /usr/local/

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

[root@localhost tmp]# cd /usr/local/

[root@localhost local]# mv mysql-5.6.26-linux-glibc2.5-x86_64 mysql

查看此目錄下文件:

[root@localhost local]# cd mysql/

[root@localhost 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

[root@localhost mysql]# mkdir -p /data/mysql

4、更改所屬的組和用戶

[root@localhost mysql]# chown -R mysql:mysql /usr/local/mysql/

[root@localhost mysql]# chown -R mysql:mysql /data/mysql/

5、初始化mysql

注釋:以mysql用戶執行mysql_install_db腳本,基本目錄為:/usr/local/mysql/,數據文件目錄為:/data/mysql/

[root@localhost mysql]# pwd
/usr/local/mysql

[root@localhost 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

解決方案:

[root@localhost mysql]# yum install -yperl-Module-Install.noarch

 

6、修改my.cnf配置文件

復制/usr/local/mysql/support-files/my-default.conf 文件到/etc/ 目錄下,覆蓋原有的配置文件mysql/my.cnf:

[root@localhost 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

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld

8、修改啟動腳本的權限為755,賦予執行權限

[root@localhost mysql]# chmod 755 /etc/init.d/mysqld

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

[root@localhost init.d]# pwd
/etc/init.d

[root@localhost init.d]# chkconfig --add mysqld

檢查是否加入到自動啟動

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

10、啟動mysql服務:

[root@localhost mysql]# service mysqld start
Starting MySQL... SUCCESS!

11、進入mysql

[root@localhost 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


設置后需要重新加載一下:

[root@localhost mysql]# source /etc/profile

再次進入mysql

[root@localhost 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> 

原創文章,作者:cnc,如若轉載,請注明出處:http://www.www58058.com/74775

(1)
cnccnc
上一篇 2017-05-04
下一篇 2017-05-04

相關推薦

  • Linux入門知識之計算機基礎

    計算機基礎、linux發行版、命令幫助獲取

    2018-01-11
  • 創建CA

    創建CA和申請證書 創建私有CA: 首先在CA服務器端創建CA。 先去看openssl的配置文件: /etc/pki/tls/openssl.cnf 一般我們不會去更改這個配置文件,但是要去看一下。我們是根據這個文件創建的CA. 這個文件里是openssl的配置文件,我們打開后只觀察與CA有關的文件。   在文本中可以看出一個主機中可以有多個CA,…

    2017-07-28
  • 從Linux小白到大?!c狼共舞的日子12(下)

    馬哥教育網絡班21期+第12周課程練習 5、為第4題中的第2個虛擬主機提供https服務,使得用戶可以通過https安全的訪問此web站點; (1)要求使用證書認證,證書中要求使用的國家(CN)、州(HA)、城市(ZZ)和組織(MageEdu); (2)設置部門為Ops,主機名為www2.stuX.com,郵件為admin@stuX.com; 1.CA生成私…

    Linux干貨 2016-12-26
  • varnish4 基礎實戰

    實驗環境 node1 192.168.0.8 varnish服務器 node2 192.168.0.3 動態web node3 192.168.0.7 靜態web node1安裝varnish ##安裝varnish yum源  # wget http://repo.varnish-cache.org/redhat/v…

    Linux干貨 2016-11-15
  • Bash Shell編程初學基礎篇之二

    Bash Shell編程初學基礎篇之二    時間如白駒過隙,一晃過去了幾周,一切的計劃都沒有變化快。當你制定計劃實施時,在這期間卻會發生許多打亂我們計劃的事情,但是我們還是要堅持下去,勝利是屬于堅持到最后的人!實踐出真理,中級基本結束了,需要回過頭了好好總結一下了。心中總有好多話想找個同行嘮嘮;不廢話了,估計大家都煩了!總有一天,你會成…

    Linux干貨 2015-05-11
  • 文件的查找作業

    1、查找/var目錄下屬主為root,且屬組為mail的所有文件 2、查找/var目錄下不屬于root、lp、gdm的、所有文件 3、查找/var目錄下最近一周內其內容修改過,同時屬主不為root,也不是postfix的文件 4、查找當前系統上沒有屬主或屬組,且最近一個周內曾被訪問過的文件 5、查找/etc目錄下大于1M且類型為普通文件的所有文件 6、查找/…

    Linux干貨 2016-08-15
欧美性久久久久