登录
首页 >  数据库 >  MySQL

Centos7一键编译安装Mysql脚本

来源:SegmentFault

时间:2023-02-24 16:08:50 225浏览 收藏

哈喽!今天心血来潮给大家带来了《Centos7一键编译安装Mysql脚本》,想必大家应该对数据库都不陌生吧,那么阅读本文就都不会很困难,以下内容主要涉及到MySQL、shell、centos7,若是你正在学习数据库,千万别错过这篇文章~希望能帮助到你!

cat > mysql.sh  /etc/my.cnf

cd ${INSTALL_DIR}/mysql/bin/;
./mysqld --defaults-file=/etc/my.cnf --basedir=${INSTALL_DIR}/mysql/ --datadir=${DATA_DIR}/mysql/ --user=mysql --initialize;

echo "
[Unit]
Description=Mysql
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=${DATA_DIR}/mysql/mysql.pid
ExecStart=${INSTALL_DIR}/mysql/support-files/mysql.server start
Restart=on-failure
PrivateTmp=false
[Install]
WantedBy=multi-user.target
" > /usr/lib/systemd/system/mysql.service


systemctl daemon-reload;systemctl start mysql;systemctl status mysql;
firewall-cmd --zone=public --add-port=${MYSQL_PORT}/tcp --permanent;firewall-cmd --reload;firewall-cmd --list-all;
rm -rf /usr/bin/mysql;ln -s  ${INSTALL_DIR}/mysql/bin/mysql /usr/bin;
rm -rf /usr/bin/mysqldump;ln -s ${INSTALL_DIR}/mysql/bin/mysqldump /usr/bin;
PASSWORD=`cat ${DATA_DIR}/mysql/mysql.err | grep "temporary password"|awk -F"root@localhost: " '{print $2}'`;
mysql --connect-expired-password -uroot -p${PASSWORD} -D mysql -e "alter user 'root'@'localhost' identified by '$MYSQL_PASSWORD';flush privileges;update user set host = '%' where user = 'root';flush privileges;"
ln -s ${INSTALL_DIR}/mysql/bin/mysqlbinlog /usr/local/bin/mysqlbinlog;
ln -s ${INSTALL_DIR}/mysql/bin/mysql /usr/local/bin/mysql;

systemctl daemon-reload;systemctl restart mysql;systemctl enable mysql;systemctl status mysql;
echo "==========> MYSQL信息 

终于介绍完啦!小伙伴们,这篇关于《Centos7一键编译安装Mysql脚本》的介绍应该让你收获多多了吧!欢迎大家收藏或分享给更多需要学习的朋友吧~golang学习网公众号也会发布数据库相关知识,快来关注吧!

声明:本文转载于:SegmentFault 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>
评论列表