yum install ncurses-devel bison -y
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./bootstrap
gmake
gmake install
cd ..
#mysql 下載地址http://dev.mysql.com/downloads/mysql/#downloads
tar zxvf mysql-5.6.11.tar.gz
cd mysql-5.6.11
mkdir -p /data/mysql
mkdir -p /usr/local/mysql
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql/ \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306php
make && make install
groupadd mysql
useradd mysql -g mysql -s /sbin/nologin
cd /usr/local/mysqlmysql
chown mysql.mysql -R .
chown mysql.mysql -R /data/mysql
cp -pr support-files/my-default.cnf /etc/my.cnf
chmod 755 scripts/mysql_install_db
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/
cp -pr support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
service mysqld start
./bin/mysqladmin -u root password '111111'
#*********************************************************
##mysql參考網址http://51ctoblog.blog.51cto.com/26414/934381
#**********************************************************linux
附錄:c++
1.mysql 編譯時參數git
斜體是較經常使用的(如下內容摘自mysql官方網站)github
參數sql |
configure 選項bootstrap |
CMake 選項bash |
CMake 說明curl |
主安裝目錄 |
--prefix=/usr |
-DCMAKE_INSTALL_PREFIX=/usr |
|
mysqld 目錄 |
--libexecdir=/usr/sbin |
-DINSTALL_SBINDIR=sbin |
該目錄相對--prefix,至關於/usr/sbin,不要加前綴(如下標“同上”的同樣) |
數據目錄 |
--localstatedir=/var/lib/mysql |
-DMYSQL_DATADIR=/var/lib/mysql |
|
配置文件my.cnf 目錄 |
--sysconfdir=/etc/mysql |
-DSYSCONFDIR=/etc/mysql |
|
插件目錄 |
--with-plugindir=/usr/lib64/mysql/plugin |
-DINSTALL_PLUGINDIR=lib64/mysql/plugin |
同上 |
Man page 目錄 |
--mandir=/usr/share/man |
-DINSTALL_MANDIR=share/mysql |
同上 |
共享數據目錄 |
--sharedstatedir=/usr/share/mysql |
-DINSTALL_SHAREDIR=share |
aclocal/mysql.m4 安裝目錄 |
庫安裝目錄 |
--libdir=/usr/lib64/mysql |
-DINSTALL_LIBDIR=lib64/mysql |
同上 |
Header 安裝目錄 |
--includedir=/usr/include/mysql |
-DINSTALL_INCLUDEDIR=include/mysql |
同上 |
信息文檔目錄 |
--infodir=/usr/share/info |
-DINSTALL_INFODIR=share/info |
同上 |
存儲引擎也是作爲插件安裝的,configure 方式接受 --with-plugins 參數指定參數方式以逗號分隔或組名形式安裝插件,但在 CMake 中各存儲引擎是以參數形式單獨配置的,如下幾個較經常使用:
· -DWITH_INNOBASE_STORAGE_ENGINE=1 INNODB 引擎
· -DWITH_ARCHIVE_STORAGE_ENGINE=1 ARCHIVE 引擎
· -DWITH_BLACKHOLE_STORAGE_ENGINE=1 BLACKHOLE 引擎
mariadb安裝腳本
#!/bin/bash groupadd mysql useradd -g mysql mysql -s /bin/false mkdir -p /data/mysql chown -R mysql:mysql /data/mysql mkdir -p /usr/local/mysql yum install -y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libtiff libtiff* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* zlib-devel gd-devel cmake wget https://github.com/MariaDB/server/archive/mariadb-10.1.12.tar.gz tar zxvf mariadb-10.1.12.tar.gz cd server-mariadb-10.1.12 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc make -j2 make install rm -rf /etc/my.cnf cd support-files/ cp -pr my-large.cnf /etc/my.cnf cp -pr mysql.server /etc/init.d/mysqld sed -i 's/^basedir=/&\/usr\/local\/mysql/g' /etc/init.d/mysqld sed -i 's/^datadir=/&\/data\/mysql/g' /etc/init.d/mysqld /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/ chmod 755 /etc/init.d/mysqld chkconfig mysqld on 35 echo 'export PATH=$PATH:/usr/local/mysql/bin'>>/etc/profile && source /etc/profile /etc/init.d/mysqld restart /usr/local/mysql/bin/mysql_secure_installation