一、虛擬環境准備
虛擬機:VMware Workstation
System:CentOS6.0(64Bit)基本安裝
二、相關組件下載地址
cmake:http://www.cmake.org/
bison:http://www.gnu.org/s/bison/
mysql:http://www.mysql.com/
M4:http://www.gnu.org/s/m4/
三、組件下載、安裝
[root@CentOS ~]# cd /usr/src/
[root@CentOS src]# wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
[root@CentOS src]# wget http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz
[root@CentOS src]# wget http://gd.tuwien.ac.at/db/mysql/Downloads/MySQL-5.5/mysql-5.5.16.tar.gz
[root@CentOS src]# wget http://ftp.gnu.org/gnu/m4/m4-1.4.16.tar.gz
⑴cmake 、bison安裝
[root@CentOS src]# tar -zxvf cmake-2.8.5.tar.gz
[root@CentOS src]# cd cmake-2.8.5
[root@CentOS cmake-2.8.5]# ./bootstrap
[root@CentOS cmake-2.8.5]# make
[root@CentOS cmake-2.8.5]# make install
[root@CentOS cmake-2.8.5]# cmake --version
cmake version 2.8.5
[root@CentOS src]# tar -zxvf bison-2.5.tar.gz
[root@CentOS src]# cd bison-2.5
[root@CentOS bison-2.5]#./configure
[root@CentOS bison-2.5]#make
[root@CentOS bison-2.5]#make install
[root@CentOS bison-2.5]# bison --version
bison (GNU Bison) 2.4.1
Written by Robert Corbett and Richard Stallman.
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
⑵mysql 安裝
[root@CentOS src]# tar -zxvf mysql-5.5.16.tar.gz
[root@CentOS src]# cd mysql-5.5.16
[root@CentOS mysql-5.5.16]# groupadd mysql www.2cto.com
[root@CentOS mysql-5.5.16]# useradd -g mysql mysql
[root@CentOS mysql-5.5.16]# 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,gb2312 \
> -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
相同功能
[root@CentOS mysql-5.5.16]# 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,gb2312 -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
[root@CentOS mysql-5.5.16]# make
[root@CentOS mysql-5.5.16]# make install
[root@CentOS mysql-5.5.16]# chmod +w /usr/local/mysql
[root@CentOS mysql-5.5.16]# chown -R mysql:mysql /usr/local/mysql
[root@CentOS mysql-5.5.16]# cd /usr/local/mysql/lib
[root@CentOS lib]# ls
libmysqlclient.a libmysqlclient_r.so.18 libmysqlclient.so.18 plugin
libmysqlclient_r.a libmysqlclient_r.so.18.0.0 libmysqlclient.so.18.0.0
libmysqlclient_r.so libmysqlclient.so libmysqlservices.a
[root@CentOS lib]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18 32Bit
[root@CentOS lib]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18 64Bit
[root@CentOS src]# cd /usr/src/mysql-5.5.16
[root@CentOS mysql-5.5.16]# mkdir -p /var/mysql/
[root@CentOS mysql-5.5.16]# mkdir -p /var/mysql/data/
[root@CentOS mysql-5.5.16]# mkdir -p /var/mysql/log/
[root@CentOS mysql-5.5.16]# chown -R mysql:mysql /var/mysql/
[root@CentOS mysql-5.5.16]# cp /usr/src/mysql-5.5.16/support-files/my-large.cnf /var/mysql/my.cnf
[root@CentOS mysql-5.5.16]# cp /usr/src/mysql-5.5.16/support-files/mysql.server /etc/init.d/mysqld
[root@CentOS mysql-5.5.16]# /usr/local/mysql/scripts/mysql_install_db \
> --defaults-file=/var/mysql/my.cnf \
> --basedir=/usr/local/mysql \
> --datadir=/var/mysql/data \
> --user=mysql
相同功能
[root@CentOS mysql-5.5.16]# /usr/local/mysql/scripts/mysql_install_db --defaults-file=/var/mysql/my.cnf --basedir=/usr/local/mysql --datadir=/var/mysql/data --user=mysql
[root@CentOS mysql-5.5.16]# chmod +x /etc/init.d/mysqld
[root@CentOS mysql-5.5.16]# vim /etc/init.d/mysqld (修改)
basedir=/usr/local/mysql
datadir=/var/mysql/data
[root@CentOS mysql-5.5.16]# chkconfig --add mysqld
[root@CentOS mysql-5.5.16]# chkconfig --level 345 mysqld on
[root@CentOS mysql-5.5.16]# service mysqld start
Starting MySQL.. SUCCESS!
[root@CentOS tmp]# mysqladmin -u root -p password 123.com
Enter password:
四、FQA常見問題
①[root@CentOS mysql-5.5.16]# service mysqld start
Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib/mysql/CentOS.LNMP.pid).
解決方案:
[root@CentOS mysql-5.5.16]# mv /etc/my.cnf my.cnf.bakcup
②[root@CentOS mysql-5.5.16]# mysqladmin -u root -p password 123.com
Enter password:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
解決方案:
[root@CentOS mysql-5.5.16]# vim /var/mysql/my.cnf
socket =/tmpl/mysql.sock 修改socket = /var/lib/mysql/mysql.sock
[root@CentOS tmp]# ln -s /tmp/mysql.sock /var/lib/mysql/
[root@CentOS tmp]# mysqladmin -u root -p password 123.com
Enter password:
聯系:QQ:64324613
本文出自 “13975309974” 博客