MySql教程

在 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

 

这篇关于在 CentOS7 源码安装 Mysql5.7的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!