最近要比較 MySQL 5.5 與 MySQL 5.6 的寫入速度,但機器只有一台,5.5 版是 yum RPM 安裝的,所以 5.6 就拿 tarball source 來編譯安裝
環境
- CentOS 6.x
- MySQL 5.6 (tarball source)
相關套件安裝
yum install -y ncurses-devel readline-devel cmake
新增使用者 (這步就不用了,因為 yum RPM 時就建立了)
useradd -d /usr/local/mysql -s /sbin/nologin -c "MySQL Server" -r mysql
下載編譯
wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.27.tar.gz tar zxf mysql-5.x.tar.gz cd mysql-5.x cmake clean . # 這邊有個點 rm -f CMakeCache.txt
cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DSYSCONFDIR:PATH=/usr/local/mysql \ -DMYSQL_TCP_PORT=3307 . # 這邊有個點
make make install
cmake . -LH 可以查看預設參數 (有個點)
cd /usr/local/mysql
vi my.cnf
[mysqld] local-infile=0 datadir=/usr/local/mysql/data socket=/tmp/mysql.sock user=mysql port=3307 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # LOGGING # general_log = 1 general_log_file = /usr/local/mysql/data/mysqld.general.log slow_launch_time = 5 slow_query_log = 1 slow_query_log_file = /usr/local/mysql/data/mysqld.slow.log skip_name_resolve log-bin=mysql-bin expire_logs_days = 14 [mysqld_safe] log-error=/usr/local/mysql/data/mysqld.log pid-file=/usr/local/mysql/data/mysqld.pid
但這裡我並沒有讓兩套 MySQL 同時運行
cp -rp /etc/my.cnf /etc/my.cnf.old ln -s /usr/local/mysql/my.cnf /etc/my.cnf service mysqld stop
初始化
scripts/mysql_install_db --user=mysql --explicit_defaults_for_timestamp --defaults-file=my.cnf
改權限
chown -R root . # 有個點 chown -R mysql data
執行運作
bin/mysqld_safe --user=mysql --explicit_defaults_for_timestamp --defaults-file=my.cnf &
改密碼
bin/mysqladmin -u root password 'new-password'
啟動執行
cp support-files/mysql.server /etc/init.d/mysql.server
留言