操做系統
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.gzmysql
1:依賴包安裝
yum list cmake
yum install cmake -y
yum install gcc-c++ -y
yum install readline-devel pcre-devel ncurses-devel bison-devel -y
2:建立目錄安裝,用戶,獲取安裝包
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.44c++
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=0sql
#DCMAKE_INSTALL_PREFIX MySQL安裝的根目錄
#DMYSQL_DATADIR 數據存放的目錄
#DMYSQL_UNIX_ADDR MySQL的sock文件目錄 mysql服務器用於監聽的套接字,必需是絕對路徑數據庫
make && make install && cd ..vim
4:安裝數據庫
cd /application/mysql/scripts/
./mysql_install_db --basedir=/application/mysql/ --datadir=/data/3306/data --user=mysql
中途有2個ok表示安裝成功centos
mkdir /data/3306/tmp/
chown -R mysql.mysql /data/3306/tmp/服務器
cp /application/mysql/bin/* /usr/local/sbin/app
cp /application/mysql/support-files/my-default.cnf /etc/my.cnf ide
vim /etc/my.cnf操作系統
[mysqld] 添加:
datadir=/data/3306/data
default-storage-engine=InnoDB
lower_case_table_names=1
port=3306
5:啓動數據庫
cd /application/mysql/bin
./mysqld_safe --defaults-file=/data/3306/data/my.cnf --user=mysql &
登陸數據庫
mysql -uroot -S /data/3306/tmp/mysql.sock
6:設置開機自啓動
cp support-files/mysql.server /etc/init.d/mysql
相關命令:
service mysql start
中止mysql服務
service mysql stop
重啓mysql服務
service mysql restart
添加到開機啓動項
chkconfig --add mysql
偶爾會遇到以下報錯FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:解決方法yum-y install autoconf