mysql5.5编译安装
Posted minger_lcm
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql5.5编译安装相关的知识,希望对你有一定的参考价值。
环境
centos7.2
源码包mysql5.5.38
mysql5.5开始,源码配置编译工具configure变成了cmake,所以先要去把cmake装上。并安装make,bison,cmake,gcc-c++,ncurses的包
首先安装依赖包
yum install make *curses* gcc gcc44* gcc-c++ gcc-g77 cmake -y
创建用户名mysql 设置不创建用户主目录、设置不能登录
useradd -M -s /sbin/nologin mysql
创建mysql存放数据库目录
mkdir -p /data/mysql
更改目录权限
chown -R mysql:mysql /data/mysql/
解压myslq源码包 进入目录
tar -xzvf mysql-5.5.38.tar.gz cd mysql-5.5.38
编译
/usr/bin/cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \\ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \\ -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \\ -DSYSCONFDIR=/etc \\ -DMYSQL_USER=mysql \\ -DMYSQL_TCP_PORT=3306 \\ -DWITH_XTRADB_STORAGE_ENGINE=1 \\ -DWITH_INNOBASE_STORAGE_ENGINE=1 \\ -DWITH_PARTITION_STORAGE_ENGINE=1 \\ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \\ -DWITH_MYISAM_STORAGE_ENGINE=1 \\ -DWITH_READLINE=1 \\ -DENABLED_LOCAL_INFILE=1 \\ -DWITH_EXTRA_CHARSETS=1 \\ -DDEFAULT_CHARSET=utf8 \\ -DDEFAULT_COLLATION=utf8_general_ci \\ -DEXTRA_CHARSETS=all \\ -DWITH_BIG_TABLES=1 \\ -DWITH_DEBUG=0
编译完成后,安装数据库
make && make install
初始化数据库
mv /etc/my.cnf /etc/my.cnf.bak
cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --defaults-file=/etc/my.cnf
vim /etc/my.cnf
sed -i \'46s#basedir=#basedir=/usr/local/mysql#g\' /etc/init.d/mysqld sed -i \'47s#datadir=#datadir=/data/mysql#g\' /etc/init.d/mysqld
#添加mysql服务 cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on # 开机启动mysql #启动服务 service mysqld restart #做链接 ln -s /usr/local/mysql/bin/mysql /usr/bin ln -fs /usr/local/mysql/bin/mysqldump /usr/bin ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18 ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql ln -s /usr/local/mysql/bin/mysqlimport /usr/local/bin/mysqlimport ln -s /usr/local/mysql/bin/mysqldump /usr/local/bin/mysqldump ln -s /usr/local/mysql/bin/mysql_config /usr/local/bin/mysql_config
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/ ln -s /usr/local/mysql/include/* /usr/local/include/
ps -ef |grep mysql 看看启动成功没
或者看端口监听没有 netstat -tnl |grep 3306
以上是关于mysql5.5编译安装的主要内容,如果未能解决你的问题,请参考以下文章