1.查看当前CentOS版本为5.5 Final
lsb_release -a
2.下载文件
下载 cmake-2.8.3.tar.gz到/usr/local/src
下载 mysql-5.5.9.tar.gz到/usr/local/src
3.更新需要的库
yum install gcc gcc-c++
yum install ncurses-devel
4.安装cmake (需要 gcc gcc-c++ 库)
cd /usr/local/src
tar zxvf cmake-2.8.3.tar.gz
cd cmake-2.8.3
./configure
make
make install
5.安装mysql (需要 cmake ncurses-devel 库)
cd /usr/local/src
tar zxvf mysql5.5.9.tar.gz
cd mysql.5.5.9
cmake .
make
make install
6.配置用户和用户组
groupadd mysql
useradd -r -g mysql mysql
7.配置权限
cd /usr/local/mysql
chown -R root:mysql .
chown -R mysql data
8.配置mysql数据库
scripts/mysql_install_db --user=mysql
cp support-files/my-medium.cnf /etc/my.cnf
9.试运行,设置root的密码
./bin/mysqld_safe &
./bin/mysqladmin -u root password 'yourpassowrd'
10.设置mysql开机自动启动服务
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 700 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 345 mysqld on
11.修改服务配置文件
vi /etc/rc.d/init.d/mysqld
根据设定需要,修改mysqld文件中的下面两项
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
12.设置默认使用utf8编码
vi /etc/my.cnf
在[client]下添加一行
default-character-set = utf8
在[mysqld]下添加一行
character-set-server = utf8
13.启动mysqld服务
service mysqld start
14.增加软连接
ln -s /usr/local/mysql/bin/mysql /usr/bin
ln -s /usr/local/mysql/bin/mysqldump /usr/bin
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
15.重启后尝试用root连接mysql
mysql -u root -p
16.成功登录后查看状态
status;
17.重设Root密码和其它安全设置(确保mysqld运行)
cd /usr/local/mysql;
./bin/mysql_secure_installtion;