操作系統(tǒng)
more /etc/centos-release
CentOS release 6.8 (Final)
mysql5.6.44版本獲取
https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.44.tar.gz
1:依賴(lài)包安裝
yum list cmake
yum install cmake -y
yum install gcc-c++ -y
yum install readline-devel pcre-devel ncurses-devel bison-devel -y
2:創(chuàng)建目錄安裝,用戶(hù),獲取安裝包
mkdir /home/setup
cd /home/setup
wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.44.tar.gz
useradd mysql -s /sbin/nologin -M
tar -zxvf mysql-5.6.44.tar.gz
3:編譯安裝
cd /home/setup/mysql-5.6.44
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6 \
-DMYSQL_DATADIR=/data/3306/data \
-DMYSQL_UNIX_ADDR=/data/3306/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_EGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
#DCMAKE_INSTALL_PREFIX MySQL安裝的根目錄
#DMYSQL_DATADIR 數(shù)據(jù)存放的目錄
#DMYSQL_UNIX_ADDR MySQL的sock文件目錄 mysql服務(wù)器用于監(jiān)聽(tīng)的套接字,必需是絕對(duì)路徑
make && make install && cd ..
4:安裝數(shù)據(jù)庫(kù)
cd /application/mysql/scripts/
./mysql_install_db --basedir=/application/mysql/ --datadir=/data/3306/data --user=mysql
中途有2個(gè)ok表示安裝成功
mkdir /data/3306/tmp/
chown -R mysql.mysql /data/3306/tmp/
cp /application/mysql/bin/* /usr/local/sbin/
cp /application/mysql/support-files/my-default.cnf /etc/my.cnf
vim /etc/my.cnf
[mysqld] 添加:
datadir=/data/3306/data
default-storage-engine=InnoDB
lower_case_table_names=1
port=3306
5:?jiǎn)?dòng)數(shù)據(jù)庫(kù)
cd /application/mysql/bin
./mysqld_safe --defaults-file=/data/3306/data/my.cnf --user=mysql &
登錄數(shù)據(jù)庫(kù)
mysql -uroot -S /data/3306/tmp/mysql.sock
6:設(shè)置開(kāi)機(jī)自啟動(dòng)
cp support-files/mysql.server /etc/init.d/mysql
相關(guān)命令:
service mysql start
停止mysql服務(wù)
service mysql stop
重啟mysql服務(wù)
service mysql restart
添加到開(kāi)機(jī)啟動(dòng)項(xiàng)
chkconfig --add mysql
偶爾會(huì)遇到如下報(bào)錯(cuò)
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
解決方法
yum-y install autoconf
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。