程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> CentOS7上編譯安裝MySQL5.6.23

CentOS7上編譯安裝MySQL5.6.23

編輯:MySQL綜合教程

CentOS7上編譯安裝MySQL5.6.23


1.下載源碼

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

2.解壓

tar zxvf mysql-5.6.23.tar.gz


3.安裝必要的包

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

4.進入mysql源碼目錄,生成makefile

cmake .

5.編譯

make

6.安裝

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

7.添加mysql用戶和組

sudo groupadd mysql
sudo useradd -r -g mysql mysql

8.修改目錄和文件權限,安裝默認數據庫

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

至此,mysql就可以啟動運行了。

9.啟動mysql

CentOS7自帶MariaDB的支持,/etc下默認存在my.cnf文件干擾mysql運行,需要先刪掉

cd /etc
sudo rm -fr my.cnf my.cnf.d

然後再/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了

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

CentOS7 不能使用service控制mysql服務,而源碼安裝的mysql也沒有提供Systemd的控制腳本。

於是編輯/etc/rc.d/rc.local文件,添加mysql的開機啟動命令。

/usr/local/mysql/bin/mysqld_safe --user=mysql &
然後給/etc/rc.d/rc.local添加可執行權限

sudo chmod a+x /etc/rc.d/rc.local

9.修改root密碼

/usr/loca/mysql/bin/mysql -uroot
use mysql;
UPDATE user SET password = PASSWORD('test2015') WHERE user = 'root';
GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'stcm2015';
FLUSH PRIVILEGES;

至此,安裝基本完成了,一個mysql就能用了。



  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved