centos7下編譯安裝mysql

下載

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz  

解壓

tar zxvf mysql-5.6.23.tar.gz 

安裝編譯環境

sudo yum install cmake gcc-c++ ncurses-devel perl-Data-Dumper  

編譯安裝

進入mysql源碼目錄,生成makefile

cmake .  

make

make install

mysql將會安裝到/usr/local/mysql路徑。

修改目錄和文件權限,初始化數據庫

cd /usr/local/mysql  
sudo chown -R mysql .  
sudo chgrp -R mysql .  
sudo scripts/mysql_install_db --user=mysql  

修改my.cnf文件

/etc下默認存在my.cnf文件干擾mysql運行,需要先刪掉,然後再/etc下重建my.cnf文件,內容如下:

# For advice on how to change settings please see  
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html  

[mysqld]  

# Remove leading # and set to the amount of RAM for the most important data  
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.  
# innodb_buffer_pool_size = 128M  

# Remove leading # to turn on a very important data integrity option: logging  
# changes to the binary log between backups.  
# log_bin  

# These are commonly set, remove the # and set as required.  
# basedir = .....  
# datadir = /data/mysql/data  
# port = .....  
# server_id = .....  
# socket = .....  

# Remove leading # to set options mainly useful for reporting servers.  
# The server defaults are faster for transactions and fast SELECTs.  
# Adjust sizes as needed, experiment to find the optimal values.  
# join_buffer_size = 128M  
# sort_buffer_size = 2M  
# read_rnd_buffer_size = 2M   

max_connection = 10000  
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES   

#binary log   
log-bin = mysql-bin  
binlog_format = mixed  
expire_logs_day = 30  

#slow query log   
slow_query_log = 1  
slow_query_log_file = /var/log/mysql/slow.log  
long_query_time = 3  
log-queries-not-using-indexes  
log-slow-admin-statements  

將mysql加入到系統服務中:

cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start

附:可能出現下面問題:

 Starting MySQL................ ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).

說明需要給/usr/local/mysql/data目錄讀寫權限這裏直接用:

sudo chmod 777 /usr/local/mysql/data

還需要重啓機器:

reboot

還有將mysql命令加入環境變量:

export PATH=/usr/local/mysql/bin:$PATH

安裝5.6版本的初始化工具

執行命令行(前提是mysql已經啓動):

mysql_secure_installation

按照提示初始化即可

以上

參考:http://blog.csdn.net/skykingf/article/details/44776057

發佈了64 篇原創文章 · 獲贊 32 · 訪問量 20萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章