perl下载安装教程CentOS7编译安装MySQL5.7.24的教程详解
⽬录
安装依赖
安oost
编译安装MySQL
配置
安装依赖
(1)cmake是新版MySQL的编译⼯具
sudo yum install gcc gcc-c++ pcre pcre-devel openssl openssl-devel
sudo yum install zlib zlib-devel cmake ncurses ncurses-devel bison bison-devel
如下的⼏个依赖在CentOS7中需要安装,CentOS6不需要
sudo yum install perl perl-devel autoconf
安oost
如果安装的MySQL5.7及以上的版本,在编译安装之前需要安oost,因为⾼版本mysql需要boots库的安装才可以正常运⾏。否则会报CMake Error at ake:81错误
1.切换到/usr/local⽬录,然后在这个⽬录下下载boost
2.解压并改名
tar zxvf boost_1_59_
mv boost_1_59_0 boost
3.在预编译安装MySQL时要加上-DWITH_BOOST=/usr/local/boost
编译安装MySQL
# 添加MySQL⽤户
useradd -s /sbin/nologin -M mysql
# 下载MySQL
wget sql/get/Downloads/MySQL-5.7/mysql-5.7.
# 解压MySQL
tar zxvf mysql-5.7.
# 进到MySQL⽬录
cd mysql-5.7.24
# 预编译
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.24 \
-DWITH_BOOST=/usr/local/boost \
-DMYSQL_UNIX_ADDR=/usr/local/mysql-5.7.24/tmp/mysql.sock \
-DMYSQL_DATADIR=/usr/local/mysql-5.7.24/data \
-
DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_INNODB_MEMCACHED=1 \
-DWITH_DEBUG=OFF \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-
DENABLED_PROFILING=ON \
-DMYSQL_MAINTAINER_MODE=OFF \
-DMYSQL_TCP_PORT=3306
# 编译&安装
make && make install
配置
# 创建软连接
cd /usr/local
ln -s mysql-5.7.24 mysql
# 添加到环境变量
vim /etc/profile
export PATH=/usr/local/mysql/bin:$PATH
export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
source /etc/profile
cd /usr/local/mysql-5.7.24
mkdir -p /usr/local/mysql-5.7.24/{data,tmp,logs,pids}
sql /usr/local/mysql-5.7.24/data
sql /usr/local/mysql-5.7.24/tmp
sql /usr/local/mysql-5.7.24/logs
sql /usr/local/mysql-5.7.24/pids
# 修改/etc/myf⽂件,编辑配置⽂件如下
[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/tmp/mysql.sock
[mysqld_safe]
log-error=/usr/local/mysql/logs/mysqld.log
pid-file=/usr/local/mysql/pids/mysqld.pid
[client]
default-character-set=utf8mb4
# 创建mysqld.log 和 mysqld.pid⽂件
touch /usr/local/mysql/logs/mysqld.log
touch /usr/local/mysql/pids/mysqld.pid
sql -R /usr/local/mysql/logs/
sql -R /usr/local/mysql/pids/
# 加⼊守护进程
cd /usr/local/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
# 初始化数据库, –initialize 表⽰默认⽣成⼀个安全的密码,–initialize-insecure 表⽰不⽣成密码
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
# 启动MySQL
service mysqld start
这⾥给⼀张/etc/myf的配置图⽰
登录MySQL,修改密码
mysql -u root -p #第⼀次登陆不需要密码,回车即可
set password for root@localhost = password('root'); #修改密码
总结
以上所述是⼩编给⼤家介绍的CentOS7编译安装MySQL5.7.24的教程详解,希望对⼤家有所帮助,如果⼤家有任何疑问请给我留⾔,⼩编会及时回复⼤家的。在此也⾮常感谢⼤家对⽹站的⽀持!

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。