編譯安裝mysql-server5.6.32手記

原由:

CentOS內置源裏面默認安裝的Mysql-server太老舊,不支持一些新方法的調用,須要從新安裝一個新版本mysql

老版本里面有數據,不想卸載,想保留庫和軟件自己sql

機器上沒有運行Docker,並且數據庫不太適合Docker化數據庫

看來編譯安裝最適合socket

 

目標:

編譯安裝Mysql-server5.6.32測試

並保留mysql-server-5.1.73-7.el6.x86_64ui


準備工做:

備份原始配置文件
(備份rpm包安裝的Mysql-server的配置文件)
cp /etc/my.cnf /etc/my.cnf.bak


下載軟件包
wget http://downloads.mysql.com/archives/get/file/mysql-5.6.32.tar.gz
tar -zxvf mysql-5.6.32.tar.gz

es5

 

具體步驟

切換到Mysql-server目錄準備編譯源碼
cd mysql-5.6.32



運行下面cmake指令,提示缺乏libncurses5-dev
yum install libncurses5-dev
失敗,由於libncurses5-dev是debian下面的包名字,而CentOS下面應該運行
yum install ncurses-devel


再次運行編譯
 cmake
 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock   
 -DDEFAULT_CHARSET=utf8  
 -DDEFAULT_COLLATION=utf8_general_ci  
 -DWITH_INNOBASE_STORAGE_ENGINE=1
 -DWITH_ARCHIVE_STORAGE_ENGINE=1    
 -DWITH_BLACKHOLE_STORAGE_ENGINE=1   
 -DMYSQL_DATADIR=/home/mysqldata    
 -DMYSQL_TCP_PORT=3306   
 -DENABLE_DOWNLOADS=1


------------------------
注意:若要從新運行配置,須要刪除目錄內CMakeCache.txt文件

rm CMakeCache.txt  
------------------------

make && make install



使用下面的命令查看是否有mysql用戶及用戶組
(因爲我這個機器上原來有rpm包安裝的Mysql全部就忽律查看或者添加用戶組的步驟啦!)

cat /etc/passwd 查看用戶列表
cat /etc/group  查看用戶組列表
若是沒有就建立

groupadd mysql
useradd -g mysql mysql
修改/usr/local/mysql權限

chown -R mysql:mysql /usr/local/mysql



修改配置文件
cp support-files/my-default.cnf /etc/my.cnf
vi /etc/my.cnf


-----my.cnf begin------
[client]
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysql]
default-character-set=utf8


[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 = /usr/local/mysql
datadir = /home/mysqldata/
port = 3306
# server_id = .....
socket = /usr/local/mysql/mysql.sock
character-set-server=utf8
# 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

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
-----my.cnf end------



初始化數據庫
cd /usr/local/mysql/
./scripts/mysql_install_db --user=mysql --datadir=/home/mysqldata

修改文件和目錄權限,不然開啓服務會報錯
chown -R mysql:root /usr/local/mysql/mysql.sock
chown -R mysql:root /usr/local/mysql

測試開啓編譯安裝的Mysql
/usr/local/mysql/bin/mysqld_safe


運行正常則添加啓動腳本

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


--------------
注意,由於我這裏有原來rpm包安裝的Mysql-server,
因此爲了避免覆蓋其啓動腳本
cp support-files/mysql.server /etc/init.d/mysql_tarball
chkconfig mysql_tarball on
service mysql_tarball start  --啓動MySQL
--------------server

相關文章
相關標籤/搜索