#基礎環境
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
#添加使用者
groupadd mysql
useradd -r -g mysql mysql
#下載下傳源碼包
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.16.tar.gz
#解壓
tar zxvf mysql-5.6.16.tar.gz && cd mysql-5.6.16
##cmake編譯:
cmake \
-DCMAKE_INSTALL_PREFIX=/opt/mysql \
-DMYSQL_DATADIR=/opt/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql3306.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
狀态:
CMake Warning (dev) in sql/CMakeLists.txt:
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
Target "mysqld" has an INTERFACE_LINK_LIBRARIES property which differs from
its LINK_INTERFACE_LIBRARIES properties.
INTERFACE_LINK_LIBRARIES:
-lpthread;sql;binlog;rpl;master;slave;sql;mysys;mysys_ssl
LINK_INTERFACE_LIBRARIES:
rt
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
WITH_MEMORY_STORAGE_ENGINE
WITH_READLINE
-- Build files have been written to: /root/mysql-5.6.16
注意::這個cmake是替代以前的./configure 步驟。如果你需要更多的參數,請參考http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html。
make && make install
安裝資料庫
cd /opt/mysql/scripts
./mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data
注冊為服務
cd /opt/mysql/support-files
###############注冊服務
cp mysql.server /etc/rc.d/init.d/mysql
#使用預設配置檔案
cp my-default.cnf /etc/my.cnf
#讓chkconfig管理mysql服務
chkconfig --add mysql
#開機啟動
chkconfig mysql on
賦予資料存放目錄權限
# chown mysql:mysql –R /opt/mysql/data
############啟動MySQL服務
service mysql start
################改變編碼,防止亂碼
SHOW VARIABLES LIKE 'character%'
修改mysql的my.cnf檔案
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
[mysql]
#############将mysql的bin加入到path中
cd ~
#我把path添加到目前使用者目錄的bashrc中,如果需要全局設定,請修改`/etc/profile`
vi .bashrc
#加入以下内容
PATH=/usr/local/mysql/bin:$PATH
export PATH
軟連接配接到/usr/bin
ln -s /opt/mysql/bin/mysql /usr/bin/
配置使用者密碼和遠端通路權限
mysql -uroot
use mysql
SET PASSWORD = PASSWORD('123456');
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
本文轉自 msj0905 51CTO部落格,原文連結:http://blog.51cto.com/sky66/1684167