RedHat 6.4源碼方式安裝mysql5.5

參考文檔:
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 mysql

相關文章
相關標籤/搜索