MySQL5.6編譯安裝

從mysql-5.6開始,Mysql改爲用cmake編譯安裝。安裝方法如下:


一、檢查&安裝cmake

[root@Mysql-249 ~]# rpm -qa cmake

cmake-2.8.12.2-4.el6.x86_64


如未安裝,用yum方式安裝cmake

yum install cmake -y


安裝其他依賴包

yum install gcc gcc-c++ cmake ncurses-devel bison perl  -y


二、環境配置

[root@Mysql-249 ~]#mkdir -p  /www/data

[root@Mysql-249 ~]#useradd mysql 

[root@Mysql-249 ~]#chown -R mysql:mysql /www/data/


三、安裝包準備

[root@Mysql-249 ~]# cd /usr/local/src/

[root@Mysql-249 src]# wget http://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.30.tar.gz

[root@Mysql-249 src]# tar -xzf mysql-5.6.30.tar.gz 

[root@Mysql-249 src]# cd mysql-5.6.30


四、編譯安裝

[root@Mysql-249 mysql-5.6.30]# cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.30 \

-DMYSQL_DATADIR=/www/data \

-DSYSCONFDIR=/etc/my.cnf \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_MEMORY_STORAGE_ENGINE=1 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DWITH_READLINE=1 \

-DMYSQL_UNIX_ADDR=/www/data/mysqld.sock \

-DENABLED_LOCAL_INFILE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DMYSQL_TCP_PORT=3306 


[root@Mysql-249 mysql-5.6.30]# make && make install



五、修改Mysql配置文件

[root@Mysql-249 mysql-5.6.30]# cat  > /etc/my.cnf <<EOF

[mysqld]

datadir=/www/data

socket=/www/data/mysqld.sock 

user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

[mysqld_safe]

log-error=/www/data/mysqld.log

pid-file=/www/data/mysqld.pid

EOF




六、添加Mysql服務,配置開機自動啓動

[root@Mysql-249 mysql-5.6.30]#cp /usr/local/mysql-5.6.30/support-files/mysql.server  /etc/init.d/mysqld 

[root@Mysql-249 mysql-5.6.30]#chkconfig --add mysqld

[root@Mysql-249 mysql-5.6.30]#chkconfig mysqld --level 345 on



七、初始化數據庫,設置Mysql超級用戶密碼

[root@Mysql-249 mysql-5.6.30]# ln -s /usr/local/mysql-5.6.30 /usr/local/mysql

[root@Mysql-249 mysql-5.6.30]# ln -s /usr/local/mysql/bin/* /usr/bin/

[root@Mysql-249 mysql-5.6.30]# ln -s /usr/local/mysql/include/* /usr/local/include/

[root@Mysql-249 mysql-5.6.30]# /usr/local/mysql/scripts/mysql_install_db  --basedir=/usr/local/mysql  --datadir=/www/data/  --user=mysql 

[root@Mysql-249 mysql-5.6.30]# /etc/init.d/mysqld start

[root@Mysql-249 mysql-5.6.30]# /usr/local/mysql/bin/mysql_secure_installation


八、Mysql測試

[root@Mysql-249 mysql-5.6.30]# mysql -uroot -p

Enter password: 

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.30 Source distribution


Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> \s

--------------

mysql  Ver 14.14 Distrib 5.6.30, for Linux (x86_64) using  EditLine wrapper


Connection id:          1

Current database:

Current user:           root@localhost

SSL:                    Not in use

Current pager:          stdout

Using outfile:          ''

Using delimiter:        ;

Server version:         5.6.30 Source distribution

Protocol version:       10

Connection:             Localhost via UNIX socket

Server characterset:    utf8

Db     characterset:    utf8

Client characterset:    utf8

Conn.  characterset:    utf8

UNIX socket:            /www/data/mysqld.sock

Uptime:                 16 sec


Threads: 1  Questions: 5  Slow queries: 0  Opens: 70  Flush tables: 1  Open tables: 63  Queries per second avg: 0.312

--------------



編譯參數說明:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.30     #Mysql安裝路徑

-DMYSQL_DATADIR=/www/data     #數據存放路徑

-DSYSCONFDIR=/etc/my.cnf             #配置文件路徑

-DWITH_MYISAM_STORAGE_ENGINE=1             #支持MyISAM存儲引擎

-DWITH_INNOBASE_STORAGE_ENGINE=1         #支持INNODB存儲引擎

-DWITH_MEMORY_STORAGE_ENGINE=1             #支持MEMORY引擎

-DWITH_ARCHIVE_STORAGE_ENGINE=1             #支持ARCHIVE引擎

-DWITH_PARTITION_STORAGE_ENGINE=1         #支持數據庫分區

-DWITH_READLINE=1                 #支持快捷鍵

-DMYSQL_UNIX_ADDR=/www/data/mysqld.sock#Unixsocket文件路徑

-DENABLED_LOCAL_INFILE=1             #允許本地導入數據庫

-DEXTRA_CHARSETS=all                 #安裝所有字符集

-DDEFAULT_CHARSET=utf8                 #設置默認字符集爲UTF8

-DDEFAULT_COLLATION=utf8_general_ci         #設置默認字符校驗

-DMYSQL_TCP_PORT=3306                 #設置Mysql端口


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章