您好,登錄后才能下訂單哦!
[root@localhost ~]# uname -r
3.10.0-862.el7.x86_64
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
[root@localhost src]# tar -zxvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
查看解壓過(guò)程是否存在報(bào)錯(cuò)
[root@localhost src]# echo $?
0
說(shuō)明:返回0表示解壓成功,否則解壓失敗
[root@localhost src]# mv mysql-5.6.39-linux-glibc2.12-x86_64 /usr/local/mysql
[root@localhost src]# ll
total 321176
-rw-r--r-- 1 root root 328882304 Dec 9 2017 mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz
[root@localhost src]# ll /usr/local/mysql/
5.創(chuàng)建mysql用戶和用戶組
[root@localhost src]# cd /usr/local/mysql/
[root@localhost mysql]# useradd mysql
6.創(chuàng)建數(shù)據(jù)庫(kù)目錄/data/mysql
[root@localhost mysql]# mkdir /data/mysql
7.初始化數(shù)據(jù)庫(kù)
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/date/mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
報(bào)錯(cuò)分析:
初始化mysql數(shù)據(jù)庫(kù)報(bào)這個(gè)錯(cuò),是因?yàn)槿鄙貲ata::Dumper這個(gè)模塊
解決辦法1:安裝aotuconf庫(kù)
yum -y install autoconf
解決辦法2:模糊搜索perl和dumper這兩個(gè)軟件包
[root@localhost mysql]# yum list | grep perl |grep -i dumper
出現(xiàn)4個(gè)Dumper相關(guān)的軟件包,如果在不知道缺少哪個(gè)包的前提下,建議依次yum安裝每個(gè)軟件包,然后再執(zhí)行數(shù)據(jù)庫(kù)初始化命令看返回結(jié)果再來(lái)執(zhí)行數(shù)據(jù)庫(kù)初始化命令,可以從兩個(gè)方面判斷數(shù)據(jù)庫(kù)初始化是否成功
a.執(zhí)行數(shù)據(jù)庫(kù)初始化過(guò)程出現(xiàn)兩個(gè)OK
b.執(zhí)行echo $?返回值是否為0說(shuō)明:echo $?的作用是檢查上一條命令執(zhí)行狀態(tài),成功返回0,失敗返回非0
8.復(fù)制mysql5.6的配置文件模板
[root@localhost mysql]# cp ./support-files/my-default.cnf /etc/my.cnf
編輯/etc/my.cnf datadir = /data/mysql socket = /tmp/mysql.sock
9.把mysql5.6數(shù)據(jù)庫(kù)的啟動(dòng)腳本移動(dòng)到/etc/init.d/mysqld
編輯數(shù)據(jù)庫(kù)啟動(dòng)腳本/etc/init.d/mysqld,修改
basedir=
datadir=
參數(shù)為
basedir=/usr/local/mysql
datadir=/data/mysql
在centos7.5上,如果想要把mysql數(shù)據(jù)庫(kù)啟動(dòng)腳本加入到系統(tǒng)開機(jī)啟動(dòng),執(zhí)行下面命令
10.啟動(dòng)MySQL數(shù)據(jù)庫(kù),執(zhí)行
[root@localhost mysql]# service mysqld start
Starting MySQL.Logging to '/data/mysql/localhost.localdomain.err'.
................. SUCCESS!
或者
[root@localhost mysql]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@localhost mysql]#
此時(shí)可查看到mysql數(shù)據(jù)庫(kù)進(jìn)程
[root@localhost mysql]# ps -ef |grep mysqld
查看數(shù)據(jù)庫(kù)監(jiān)控的端口為3306
[root@localhost mysql]# netstat -nlpt
11.從命令行啟動(dòng)mysql服務(wù)
[root@localhost mysql]# /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid &
[root@localhost ~]# ps -ef |grep mysqld
root 20630 17325 0 02:09 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid
mysql 20767 20630 0 02:09 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/mysql.sock
root 20861 20802 0 02:10 pts/1 00:00:00 grep --color=auto mysqld
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。