mysql数据库源码安装:
源码地址:wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.35.tar.gz
#安装前准备,将编译工具、依赖环境通过yum安装
yum install cmake ncurses-devel ncurses gcc gcc-c++ perl perl-devel perl-Data-Dumper -y
#预编译(根据实际更改对应参数值)这里安装路径为/usr/local/mysql,数据库路径为/mysql/data
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_TCP_PORT=3306 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/mysql/data -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock
编译安装(根据实际情况,我这里是2核cpu)
make -j2 && make install
创建用户及数据库目录
useradd -s /sbin/nologin mysql
mkdir -p /mysql/data && chown -R mysql.mysql /mysql/data
初始化mysqld数据库
scripts/mysql-install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data
进入安装后目录,拷贝启动脚本,设置目录权限
cd /usr/local/mysql
cp support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld 添加以下2行
#chkconfig 2345 99 20
#describtion service for mysqld
chkconfig --add mysqld 将mysqld服务添加为系统服务
chkconfig mysqld on
chown -R mysql.mysql /usr/local/mysql
ln -s bin/* /usr/bin/
启动mysql服务
service mysqld start