注意:MySQL自5.5以后采用cmake方式安装
安装mysql5.5.13
groupadd mysql //所以在这里我们要建一个msyql的用户和组
useradd -g mysql mysql -s /usr/sbin/nologin
mkdir /usr/local/mysql //创建目录
mkdir /usr/local/mysql/data
进入mysql-5.5.13的解压目录:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql && make && make install
进入mysql的安装目录/usr/local/mysql下:
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql //初始化mysql数据库
cp support-files/my-medium.cnf /usr/local/mysql/my.cnf //copy配置文件
chown -R mysql:mysql /usr/local/mysql //更改权限
vi /usr/local/mysql/my.cnf //加上以下内容
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
log-error = /usr/local/mysql/mysql_error.log
pid-file = /usr/local/mysql/mysql.pid
user = mysql
tmpdir = /tmp
启动mysql bin/mysqld_safe --user=mysql & 或使用下列命令把mysql添加为系统服务。
cd /usr/local/mysql/support-files/
cp ./mysql.server /etc/init.d/mysqld
/etc/init.d/mysqld start