标题:
[教程]
升级到MYSQL8.0脚本
[打印本页]
作者:
windsage
时间:
2019-3-9 16:25
标题:
升级到MYSQL8.0脚本
#!/bin/bash
# mysql 8.0 update scripts
# Author: wdlinux
# Url: http://www.wdlinux.cn
# Modify: windsage
IN_DIR="/www/wdlinux"
if [ ! $1 ];then
MYS_VER="8.0.15"
else
MYS_VER=$1
fi
echo "升级有风险 操作需谨慎"
echo "欢迎学习交流互助提高"
echo "qq:242013800"
echo
read -p "DO YOU REALLY WANT TO UPDATE? (Y/N): " yn
if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then
echo "MYSQL IS NOW UPDATING!"
else
exit
fi
echo
echo "-------------------------------------------------------------"
echo
if [ ! -f mysql-${MYS_VER}.tar.gz ];then
# 因mysql5.7需要boost,所以这个直接是包含boost的源码包
wget -c https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-${MYS_VER}.tar.gz -O mysql-${MYS_VER}.tar.gz
fi
yum install -y cmake bison libmcrypt-devel libjpeg-devel libpng-devel freetype-devel curl-devel openssl-devel libxml2-devel zip unzip
if [ ! -d $IN_DIR/mysql-${MYS_VER} ];then
mkdir -p $IN_DIR/mysql-${MYS_VER}
# 数据库文件夹默认要求是data
mkdir -p $IN_DIR/mysql-${MYS_VER}/data
fi
if [ ! -d mysql-${MYS_VER} ];then
tar zxvf mysql-${MYS_VER}.tar.gz
fi
cd mysql-${MYS_VER}
echo "START CONFIGURING MYSQL"
sleep 3
make clean
cmake \
-DCMAKE_INSTALL_PREFIX=$IN_DIR/mysql-$MYS_VER \
-DSYSCONFDIR=$IN_DIR/etc \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_SSL=bundled \
-DWITH_DEBUG=OFF \
-DWITH_EXTRA_CHARSETS=complex \
-DENABLED_PROFILING=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_BOOST=boost/boost_1_68_0/
[ $? != 0 ] && echo "NO! CONFIGURE ERROR! :(" && exit
echo "START MAKE"
sleep 3
make
[ $? != 0 ] && echo "NO! MAKE ERROR! :(" && exit
echo "START MAKE INSTALL"
sleep 3
make install
[ $? != 0 ] && echo "NO! MAKE INSTALL ERROR! :(" && exit
service mysqld stop
# 建立备份文件夹,这个可以自定义设置
if [ ! -d /mnt/mysql_bk ];then
mkdir -p /mnt/mysql_bk
cp -pR /www/wdlinux/mysql/var/* /mnt/mysql_bk
fi
rm -f /www/wdlinux/mysql
ln -sf $IN_DIR/mysql-$MYS_VER /www/wdlinux/mysql
sh scripts/mysql_install_db.sh --user=mysql --basedir=/www/wdlinux/mysql --datadir=/www/wdlinux/mysql/data
chown -R mysql.mysql /www/wdlinux/mysql
chown -R mysql.mysql /www/wdlinux/mysql/data
mv /www/wdlinux/mysql/data/mysql /www/wdlinux/mysql/data/mysqlo
cp support-files/mysql.server /www/wdlinux/init.d/mysqld
chmod 755 /www/wdlinux/init.d/mysqld
service mysqld restart
ln -sf $IN_DIR/mysql/lib/libmysqlclient.so.20. /usr/lib/libmysqlclient.so.20
cd ..
rm -rf mysql-${Ver}/
# rm -rf mysql-${Ver}.tar.gz
sleep 2
service mysqld restart
sleep 2
mysqld --initialize --user=mysql --console
# 或者把备份的数据库复制回来,注意不要覆盖performance_schema
# cp -pR /mnt/mysql_bk/* /www/wdlinux/mysql/data/
echo
echo "-------------------------------------------------------------"
echo "数据库需要初始化,自动生成的密码会存入mysql的日志,默认在/var/log/mysql/error.log"
echo
echo "此时查看mysql日志,应该一切正常了,但新手朋友注意了,此时你的httpd无法启动了,需要编译安装php。"
echo
复制代码
有不足的地方欢迎指出
作者:
admin
时间:
2019-3-10 10:53
数据文件,最好不要直接复制,版本差距大时,应该会有问题
可以使用mysqldump导出再导入
作者:
windsage
时间:
2019-4-25 10:02
#!/bin/bash
# mysql 8.0 update scripts
# Author: wdlinux
# Url: http://www.wdlinux.cn
# Modify: windsage
IN_DIR="/www/wdlinux"
if [ ! $1 ];then
MYS_VER="8.0.15"
else
MYS_VER=$1
fi
echo "升级有风险 操作需谨慎"
echo "欢迎学习交流互助提高"
echo "qq:242013800"
echo
read -p "DO YOU REALLY WANT TO UPDATE? (Y/N): " yn
if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then
echo "MYSQL IS NOW UPDATING!"
else
exit
fi
echo
echo "-------------------------------------------------------------"
echo
if [ ! -f mysql-boost-${MYS_VER}.tar.gz ];then
# 因mysql5.7需要boost,所以这个直接是包含boost的源码包
wget -c https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-${MYS_VER}.tar.gz
fi
yum install -y cmake bison libmcrypt-devel libjpeg-devel libpng-devel freetype-devel curl-devel openssl-devel libxml2-devel zip unzip
if [ ! -d $IN_DIR/mysql-${MYS_VER} ];then
mkdir -p $IN_DIR/mysql-${MYS_VER}
# 数据库文件夹默认要求是data
mkdir -p $IN_DIR/mysql-${MYS_VER}/data
fi
if [ ! -d mysql-${MYS_VER} ];then
tar zxvf mysql-${MYS_VER}.tar.gz
fi
cd mysql-${MYS_VER}
echo "START CONFIGURING MYSQL"
sleep 3
mkdir -p build
cd build/
make clean
cmake. \
-DCMAKE_INSTALL_PREFIX=$IN_DIR/mysql-$MYS_VER \
-DSYSCONFDIR=$IN_DIR/etc \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_SSL=bundled \
-DWITH_DEBUG=OFF \
-DWITH_EXTRA_CHARSETS=complex \
-DENABLED_PROFILING=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DENABLE_DOWNLOADS=1 \
-DWITH_BOOST=../boost/boost_1_68_0/
[ $? != 0 ] && echo "NO! CONFIGURE ERROR! :(" && exit
echo "START MAKE"
sleep 3
make
[ $? != 0 ] && echo "NO! MAKE ERROR! :(" && exit
echo "START MAKE INSTALL"
sleep 3
make install
[ $? != 0 ] && echo "NO! MAKE INSTALL ERROR! :(" && exit
复制代码
service mysqld stop
# 建立备份文件夹,这个可以自定义设置
if [ ! -d /mnt/mysql_bk ];then
mkdir -p /mnt/mysql_bk
cp -pR /www/wdlinux/mysql/var/* /mnt/mysql_bk
fi
rm -f /www/wdlinux/mysql
ln -sf $IN_DIR/mysql-$MYS_VER /www/wdlinux/mysql
sh scripts/mysql_install_db.sh --user=mysql --basedir=/www/wdlinux/mysql --datadir=/www/wdlinux/mysql/data
chown -R mysql.mysql /www/wdlinux/mysql
chown -R mysql.mysql /www/wdlinux/mysql/data
mv /www/wdlinux/mysql/data/mysql /www/wdlinux/mysql/data/mysqlo
cp support-files/mysql.server /www/wdlinux/init.d/mysqld
chmod 755 /www/wdlinux/init.d/mysqld
service mysqld restart
ln -sf $IN_DIR/mysql/lib/libmysqlclient.so.20. /usr/lib/libmysqlclient.so.20
cd ..
rm -rf mysql-${Ver}/
# rm -rf mysql-${Ver}.tar.gz
sleep 2
service mysqld restart
sleep 2
mysqld --initialize --user=mysql --console
# 或者把备份的数据库复制回来,注意不要覆盖performance_schema
# cp -pR /mnt/mysql_bk/* /www/wdlinux/mysql/data/
echo
echo "-------------------------------------------------------------"
echo "数据库需要初始化,自动生成的密码会存入mysql的日志,默认在/var/log/mysql/error.log"
echo
echo "此时查看mysql日志,应该一切正常了,但新手朋友注意了,此时你的httpd无法启动了,需要编译安装php。"
echo
复制代码
修改了一下 解决In-source builds are not allowed
作者:
冬至雨
时间:
2019-5-18 12:03
这个脚本对菜鸟来说,是比较困难的
作者:
24447678@qq.com
时间:
2019-5-24 17:38
START CONFIGURING MYSQL
make: *** 没有规则可以创建目标“clean”。 停止。
报错了啊
作者:
andylau918
时间:
2019-7-10 13:44
有站長能成功更新嗎?謝謝
作者:
yixianbin
时间:
2019-8-9 15:36
没有 我准备试试
欢迎光临 WDlinux官方论坛 (http://wdlinux.cn/bbs/)
Powered by Discuz! 7.2