数据库
首页 > 数据库> > 在 CentOS7 源码安装 Mysql5.7

在 CentOS7 源码安装 Mysql5.7

作者:互联网

 

 

安装环境

系统版本:CentOS Linux release 7

mysql版本:mysql-5.7.27

数据库安装路径:/home/mysql/DATA/

 

安装步骤

# 安装常用的依赖包
yum  -y  install gcc gcc-c++ cmake make ncurses-devel  perl perl-develperl-DBD-MySQL

# mysql 5.7 安装需要用到boost
# 下载并解压到/usr/local/boost/
ls /usr/local/boost/

boost   boost-build.jam  boost.css  bootstrap.bat  doc   index.html  Jamroot  LICENSE_1_0.txt  rst.css  tools
boostcpp.jam     boost.png  bootstrap.sh   index.htm  INSTALL     libs     more             status

# 解压mysql5.7安装包
tar -xvf mysql-5.7.27.tar.gz
cd xvf mysql-5.7.27

# 编译安装
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock  -DDEFAULT_CHARSET=utf8  -DDEFAULT_COLLATION=utf8_general_ci  -DWITH_MYISAM_STORAGE_ENGINE=1  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_ARCHIVE_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1  -DWITH_MEMORY_STORAGE_ENGINE=1  -DWITH_READLINE=1   -DENABLED_LOCAL_INFILE=1  -DMYSQL_DATADIR=/home/mysql/DATA   -DMYSQL_USER=mysql   -DMYSQL_TCP_PORT=3306  -DWITH_BOOST=/usr/local/boost/
make
make install 


chown -R mysql:mysql /usr/local/mysql


#  mysql5.7 使用 mysqld --initialize 替代mysql5.6 的mysql_install_db 初始化数据库
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/home/mysql/DATA/ --explicit_defaults_for_timestamp
正常生成日志如下:
2021-11-19T11:18:17.370279Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-11-19T11:18:17.431811Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-11-19T11:18:17.491813Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 65142cc1-492a-11ec-9e74-000c298e12ed.
2021-11-19T11:18:17.493299Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-11-19T11:18:17.494781Z 1 [Note] A temporary password is generated for root@localhost: xxxxx 这里会随机生成临时密码

chown -R mysql:mysql /home/mysql/DATA

# 添加环境变量
 export MYSQL_HOME=/usr/local/mysql
 export PATH=${MYSQL_HOME}/bin:$PATH
# 把上面两行加入配置文件以永久生效 vi /etc/profile source /etc/profile # 拷贝启动脚本 cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld # 启动mysql /etc/init.d/mysqld start

 

标签:--,boost,Mysql5.7,CentOS7,源码,usr,mysql,DWITH,local
来源: https://www.cnblogs.com/yuejunasia/p/15578907.html