1. 程式人生 > >MySQL5.5編譯方式安裝實戰

MySQL5.5編譯方式安裝實戰

mysql


技術分享

第一章 安裝cmake

[root@oldboy ~]# mkdir -p /home/oldboy/tools
[root@oldboy ~]# cd /home/oldboy/tools/
[root@oldboy tools]# rz -y 
上傳cmake-2.8.8.tar.gz和mysql-5.5.32.tar.gz
[root@oldboy tools]# ls
cmake-2.8.8.tar.gz  mysql-5.5.32.tar.gz
[root@oldboy tools]# tar xf cmake-2.8.8.tar.gz 
[root@oldboy tools]# ls
cmake-2.8.8  cmake-2.8.8.tar.gz  mysql-5.5.32.tar.gz
[root@oldboy tools]# cd cmake-2.8.8
[root@oldboy cmake-2.8.8]# ./configure
最後提示
CMake has bootstrapped.  Now run gmake.
[root@oldboy cmake-2.8.8]# gmake
[root@oldboy cmake-2.8.8]# gmake install
[root@oldboy cmake-2.8.8]# cd ..

第二章 安裝MySQL

2.1安裝mysql依賴包

[root@oldboy tools]# yum install ncurses-devel -y

2.1cmake前準備工作

[root@oldboy tools]# ls
cmake-2.8.8  cmake-2.8.8.tar.gz  mysql-5.5.32.tar.gz
[root@oldboy tools]# tar xf mysql-5.5.32.tar.gz 
[root@oldboy tools]# cd mysql-5.5.32
[root@oldboy mysql-5.5.32]# mkdir -p /application/mysql-5.5.32
[root@oldboy mysql-5.5.32]# mkdir -p /application/mysql-5.5.32/data
[root@oldboy mysql-5.5.32]# useradd mysql -s /sbin/nologin -M

cmake編輯前檢查環境

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 -DMYSQL_DATADIR=/application/mysql-5.5.32/data -DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0

make 編譯&& make install 安裝

[root@oldboy mysql-5.5.32]# make && make install

安裝完成後做個軟連接

[root@oldboy mysql-5.5.32]# ln -s /application/mysql-5.5.32/ /application/mysql
[root@oldboy mysql-5.5.32]# cd ..
[root@oldboy tools]# ls
cmake-2.8.8  cmake-2.8.8.tar.gz  mysql-5.5.32  mysql-5.5.32.tar.gz

選擇配置文件:

測試環境選小的,生產環境可以根據硬件選擇,例如:my-innodb-heavy-4G.cnf

選擇一個小的模板my-small.cnf放到/etc/my.cnf(因為是測試環境,如果生產環境,可以選擇大的模板)

[root@oldboy tools]# /bin/cp mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf

配置環境變量:

[root@oldboy tools]# echo ‘export PATH=/application/mysql/bin:$PATH‘ >>/etc/profile
[root@oldboy tools]# tail -1 /etc/profile
[root@oldboy tools]# source /etc/profile
[root@oldboy tools]# echo $PATH

故障問題:http://oldboy.blog.51cto.com/2561410/1122867


初始化(容易出錯的地方)

[root@oldboy mysql-5.5.32]# mkdir -p /application/mysql/data/
#建立mysql數據文件目錄
[root@oldboy tools]# chown -R mysql.mysql /application/mysql/data/
[root@oldboy tools]# chown -R 1777 /tmp/
#授權mysql用戶訪問mysql的安裝目錄
[root@oldboy tools]# cd /application/mysql/scripts/
[root@oldboy scripts]# ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
初始化成功的標誌如下兩個OK所示:
WARNING: The host ‘oldboy‘ could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK
[root@oldboy scripts]# cd /home/oldboy/tools/mysql-5.5.32
[root@oldboy mysql-5.5.32]# /bin/cp support-files/mysql.server /etc/init.d/mysqld
[root@oldboy mysql-5.5.32]# chmod +x /etc/init.d/mysqld
[root@oldboy mysql-5.5.32]# /etc/init.d/mysqld start


本文出自 “sandshell” 博客,請務必保留此出處http://sandshell.blog.51cto.com/9055959/1977647

MySQL5.5編譯方式安裝實戰