RedHat 6.4原始碼方式安裝mysql5.5

kisslfcr發表於2016-07-27
參考文件:
http://dev.mysql.com/downloads/file/?id=463397 下載地址
http://dev.mysql.com/doc/refman/5.7/en/ 文件地址


準備rpm包
yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*
安裝cmake
官網下載cmake,為綠色軟體,新增環境變數後:
[root@ycr ~]# which cmake
/u02/cmake-3.6.1-Linux-x86_64/bin/cmake
安裝boost
下載後解壓,進入解壓目錄後執行
./booststrap之後執行./b2此過程耗時
安裝ncurses-5.9.tar.gz
./configure
make
make install


解壓安裝包mysql-5.5.50
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysql/data \
-DMYSQL_USER=mysql


執行完成後make和make install
chmod +w /usr/local/mysql 
chown -R mysql:mysql /usr/local/mysql
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
cp my-large.cnf /etc/my.cnf 
cp mysql.server /etc/init.d/mysqld
 
vi /etc/my.cnf新增如下行
basedir = /usr/local/mysql    
datadir = /usr/local/mysql     此處應該和下面的統一,不然會啟動報錯
log-error = /usr/local/mysql-5.5.14/mysql_error.log
pid-file = /usr/local/mysql-5.5.14/data/mysql.pid
default-storage-engine=MyISAM
user = mysql


mysql初始化,執行如下命令
/usr/local/mysql/scripts/mysql_install_db \
--basedir=/usr/local/mysql \        此處應該和上面的統一,不然啟動報錯
--datadir=/var/mysql/data \
--user=mysql 


加入開機啟動mysql
chmod +x /etc/init.d/mysqld 
vi /etc/init.d/mysqld新增如下行
basedir=/usr/local/mysql
datadir=/var/mysql/data


chkconfig --add mysqld 
chkconfig --level 345 mysqld on 


為MySQL配置環境變數,以後使用起來方便 
# export PATH=/usr/local/mysql/bin:$PATH
啟動mysql
service mysqld start 



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29135257/viewspace-2122601/,如需轉載,請註明出處,否則將追究法律責任。

相關文章