**
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.25.tar.gz
wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz (mysql编译环境需要boost文件)
yum -y install ncurses-devel.x86_64 openssl-devel bison gcc gcc-c++.x86_64 make cmake 安装依赖
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
tar xf mysql-5.7.25.tar.gz
cd mysql-5.7.25/
tar xf /root/boost_1_59_0.tar.gz
cmake . -DWITH_BOOST=boost_1_59_0/ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DMYSQL_DATADIR=/usr/local/mysql/data -DINSTALL_MANDIR=/usr/share/man -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DEXTRA_CHARSETS=all -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1
(
cmake . \
-DWITH_BOOST=boost_1_59_0/ \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DINSTALL_MANDIR=/usr/share/man \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_READLINE=1 \
-DWITH_SSL=system \ 编译ssl功能
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 安装innodb存储引擎(默认安装的只有csv.myisam,myisammrg和heap)
}
make
make install
cd /usr/local/mysql/ (初始化)
mkdir mysql-files mysql的必要文件
chown -R mysql.mysql . (设置当前文件夹下的文件的所有者和所有组)
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data (初始化指定安装目录和数据目录,产生mysql初始密码)
vim /etc/my.cnf 编写配置文件
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
cp support-files/mysql.server /etc/init.d/mysqld 添加启动脚本
chkconfig --add mysqld 添加到开机启动
systemctl daemon-reload
systemctl start mysqld
echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile 设置环境变量,生成mysql命令
source /etc/profile
mysqladmin -uroot -p'8F<.n;-Mvt4m' password "Swy123456@" 修改密码,初始密码为初始化时最后一行给的密码
**
Centos7编译安装mysql5.7
最新推荐文章于 2024-08-12 17:27:21 发布