1. mysql高版本之后,利用cmake进行编译安装
2. yum安装cmake
#yum -y install cmake |
3.下载mysql源码包
#wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.35.tar.gz |
4. 安装mysql
1>. 创建mysql用户
#useradd -M -s /sbin/nologin mysql |
2>. 创建mysql安装目录和数据库存放目录
#mkdir -p /usr/local/mysql/data |
3>. 编译安装mysql
#yum -y install ncurses-devel #如果不安装的话,下面编译的过程中会报错 #tar -zxvf mysql-5.5.35.tar.gz #cd mysql-5.5.35#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEF/etc/ld.so.confAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 #make && make install |
4> 编译参数说明
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安装目录 -DINSTALL_DATADIR=/usr/local/mysql/data //数据库存放目录 -DDEFAULT_CHARSET=utf8 //使用utf8字符 -DDEFAULT_COLLATION=utf8_general_ci //校验字符 -DEXTRA_CHARSETS=all //安装所有扩展字符集 -DENABLED_LOCAL_INFILE=1 //允许从本地导入数据 |
5.mysql配置
1>. 设置mysql目录权限
#cd /usr/local/mysql/ #chown -R root:mysql . #chown -R mysql:mysql data |
2>. 初始化mysql
#cd /usr/local/mysql #cp support-files/my-medium.cnf /etc/my.cnf #./scripts/mysql_install_db --user=mysql |
3>. 环境变量设置
#echo "/usr/local/mysql/lib" >> /etc/ld.so.conf #ldconfig #export PATH=$PATH:/usr/local/mysql/bin/ #echo "PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile |
4>. mysql开机启动设置
#cd /usr/local/mysql #./bin/mysqld_safe --user=mysql >/dev/null & //手动启动mysql #cp support-files/mysql.server /etc/init.d/mysql #chmod +x /etc/init.d/mysql #chkconfig --add mysql #chkconfig mysql on |
5>. 连接mysql
#mysql -uroot -p //默认没有密码,直接回车 #mysqladmin -u root password '密码' //设置root密码 |
参考文档:http://www.cnblogs.com/fly1988happy/archive/2011/11/21/2257682.html