[TOC] 1.MySQL安裝前準備 1.1.安裝依賴包 1.2.安裝cmake 1.3.創建用戶 2.MySQL下載安裝 2.1.創建軟體下載目錄 2.2.下載並上傳到/server/tools 2.3.解壓 2.4.安裝 3.配置並啟動 3.1.創建軟鏈接 3.2.拷貝配置文件到/etc 3.3 ...
目錄
1.MySQL安裝前準備
1.1.安裝依賴包
yum install -y ncurses-devel libaio-devel
1.2.安裝cmake
yum install cmake -y
1.3.創建用戶
useradd -s /sbin/nologin -M mysql
id mysql
2.MySQL下載安裝
2.1.創建軟體下載目錄
mkdir -p /server/tools
cd /server/tools/
2.2.下載並上傳到/server/tools
https://downloads.mysql.com/archives/community/
2.3.解壓
cd /server/tools
tar xf mysql-5.6.36.tar.gz
2.4.安裝
cd mysql-5.6.36
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.36 \
-DMYSQL_DATADIR=/application/mysql-5.6.36/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.6.36/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_ZLIB=bundled \
-DWITH_SSL=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_DEBUG=0
make && make install
3.配置並啟動
3.1.創建軟鏈接
ln -s /application/mysql-5.6.36/ /application/mysql
3.2.拷貝配置文件到/etc
cd /application/mysql
cp support-files/my*.cnf /etc/my.cnf
3.3.初始化資料庫
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data --user=mysql
3.4.創建目錄並授權
mkdir -p /application/mysql/tmp
chown -R mysql.mysql /application/mysql/
3.5.複製啟動腳本到/etc/init.d/mysqld
cp support-files/mysql.server /etc/init.d/mysqld
3.6.啟動資料庫
/etc/init.d/mysqld start
netstat -lntup|grep 330
3.7.配置環境變數
echo 'PATH=/application/mysql/bin/:$PATH' >>/etc/profile
tail -1 /etc/profile
source /etc/profile
echo $PATH
mysql