公司用ubuntu系统比较多,重新做了一遍ubuntu的编译过程,具体编译安装过程如下
首先我们更新下包
apt-get update -y
安装依赖包
apt-get install libncurses5-dev -y
准备mysql和cmake源码包
我下载的版本是
cmake-2.8.12.tar.gz mysql-5.5.20.tar.gz
首先编译安装cmake
tar -zxvf cmake-2.8.12.tar.gz ./bootstrap make && make install
然后我们开始安装mysql
groupadd mysql useradd -g mysql mysql -s /sbin/nologin mkdir -p /data/mysql chown -R mysql:mysql /data/mysql mkdir -p /usr/local/mysql cd /usr/local/src tar zxvf mysql-5.5.20.tar.gz cd mysql-5.5.20 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc make && make install cd /usr/local/mysql cp ./support-files/my-huge.cnf /etc/my.cnf vi /etc/my.cnf datadir = /data/mysql :wq! ./scripts/mysql_install_db --user=mysql
创建mysql服务
cp ./support-files/mysql.server /etc/init.d/mysqld
vi /etc/init.d/mysqld basedir = /usr/local/mysql datadir = /data/mysql
添加mysql到环境变量
vi /etc/profile export PATH=$PATH:/usr/local/mysql/bin :wq!
最后添加mysql开机启动,和centos是有区别的,defaults后面的序号可以自定
cd /etc/init.d update-rc.d mysqld defaults 50 #显示如下就是OK了 Adding system startup for /etc/init.d/mysqld ... /etc/rc0.d/K50mysqld -> ../init.d/mysqld /etc/rc1.d/K50mysqld -> ../init.d/mysqld /etc/rc6.d/K50mysqld -> ../init.d/mysqld /etc/rc2.d/S50mysqld -> ../init.d/mysqld /etc/rc3.d/S50mysqld -> ../init.d/mysqld /etc/rc4.d/S50mysqld -> ../init.d/mysqld /etc/rc5.d/S50mysqld -> ../init.d/mysqld
卸载mysql开机启动脚本
cd /etc/init.d update-rc.d -f mysqld remove #显示如下就是删除了开机启动 Removing any system startup links for /etc/init.d/mysqld ... /etc/rc0.d/K50mysqld /etc/rc1.d/K50mysqld /etc/rc2.d/S50mysqld /etc/rc3.d/S50mysqld /etc/rc4.d/S50mysqld /etc/rc5.d/S50mysqld /etc/rc6.d/K50mysqld
当然你可以添加到/etc/rc.local里面,需要将你的启动命令添加到exit 0前面
最后是启动mysql数据库
/etc/init.d/mysqld start #或者 service mysqld start