前提:安装cmake(mysql5.5以后是通过cmake来编译的)到网络去下载一下吧,安装方法如下:
[[email protected] soft]#tar -xzvf cmake-2.6.4.tar.gz
[[email protected] cmake-2.6.4]#./configure --prefix=/usr/local/cmake
[[email protected] cmake-2.6.4]#make
[[email protected] cmake-2.6.4]#make install
#创建用户和用户组与赋予数据存放目录权限
[[email protected] ~]#groupadd mysql
[[email protected] ~]#useradd -g mysql mysql
#解压
[[email protected] soft]# tar -zxvf mysql-5.5.29.tar.gz
#安装mysql
[[email protected] mysql]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql/database -
DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysqld.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -
DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -
DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock -DMYSQL_USER=mysql -DWITH_DEBUG=0
(注意:)
如果cmake时出现 command not found 的字样时,请在终端执行下面命令
[[email protected] mysql]# export PATH=/usr/local/cmake/bin:$PATH
[[email protected] mysql]# make
[[email protected] mysql]# makeinstall
#设置权限
[[email protected] mysql]#chown -R mysql:mysql /usr/local/mysql/
#初始化mysqldb
[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/database
#设置数据库权限:
[[email protected] mysql]# chown mysql:mysql -R /data/mysql/database
#配置mysql
[[email protected] support-files]# cp my-large.cnf /etc/my.cnf
[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld
[[email protected] support-files]# chmod +x /etc/init.d/mysqld
#启动mysql
[[email protected] ~]# /etc/init.d/mysqld start
#连接数据库
[[email protected] mysql]# /usr/local/mysql/bin/mysql -u root -p