下载源码
下载5.5的源码包,现在官方网站也好,第三方数据源也好,源码包都越来越少,建议多保存些源码包。
依赖包安装
yum install gcc-c++ cmake ncurses-devel zlib-devel bison bison-devel
其中CentOS6.x中本地yum源BUG,可能需要手动安装:rpm -ivh /media/dvd2/Packages/bison-devel-2.4.1-5.el6.x86_64.rpm
安装过程
1.解压并进入源代码根目录:tar xf mysql-5.5.57.tar.gz;cd mysql-5.5.57
cmake \
-DCMAKE_INSTALL_PREFIX=/app/mysql/ \
-DMYSQL_DATADIR=/app/mysql/data/ \
-DSYSCONFDIR=/app/mysql/ \
-DMYSQL_UNIX_ADDR=/app/mysql/data/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITHOUT_PERFSCHEMA_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DENABLE_DTRACE=0 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1
可以通过命令查看,当前配置生效的参数,比如查找缺少的依赖:cmake . -LAH|grep NOTFOUND3.
3.编译安装:make&&make install
4.添加环境变量:echo 'export PATH=/app/mysql/bin:$PATH'>>/etc/bashrc;. /etc/bashrc
5.data目录授权:chown -R mysql.mysql /app/mysql/data/ -v6.
6.初始化数据库:/app/mysql/scripts/mysql_install_db --user=mysql --basedir=/app/mysql/ --datadir=/app/mysql/data/
7.处理配置文件:cp /app/mysql/support-files/my-small.cnf /app/mysql/my.cnf;rm /etc/my.cnf
8.处理启动脚本:cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
9.启动服务:/etc/init.d/mysqld start
10.修改密码:mysqladmin -u root password '123456'