shell脚本实战之编译mysql

举报
互联网老辛 发表于 2021/06/09 00:44:32 2021/06/09
【摘要】 #!/bin/bash yum remove -y mysql mysql-server clear echo ‘This shell will Auto Install Mysql5.6’ yum install -y cmake ncurses-devel tar -xf mysql-5.6.26.tar.gz -C /usr/local/src &amp...

#!/bin/bash

yum remove -y mysql mysql-server

clear

echo ‘This shell will Auto Install Mysql5.6’

yum install -y cmake ncurses-devel

tar -xf mysql-5.6.26.tar.gz -C /usr/local/src && cd /usr/local/src/mysql-5.6.26

useradd -M -s /sbin/nologin mysql

mkdir /usr/local/mysql

cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_EXTRA_CHARSETS=all \

-DWITH_MYISAM_STORAGE_ENGINE=1\

-DWITH_INNOBASE_STORAGE_ENGINE=1\

-DWITH_MEMORY_STORAGE_ENGINE=1\

-DWITH_READLINE=1\

-DENABLED_LOCAL_INFILE=1\

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DMYSQL-USER=mysql

make -j 3 && make install

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

/usr/local/mysql/scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data

mv /etc/my.cnf /etc/my.cnf.bak

cp -r /usr/local/mysql/support-file/my-default.cnf /etc/my.cnf

sed -i ‘/^[mysqld]/adatadir = /usr/local/mysql/data’ /etc/my.cnf

sed -i ‘/^[mysqld]/abasedir = /usr/local/mysql’ /etc/my.cnf

cp -r /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

echo “PATH=/usr/local/mysql/bin:$PATH” >>/etc/profile

service mysqld restart

echo

echo “install success”

source /etc/profile

echo “source /etc/profile” >>/etc/rc.local

service mysqld restart

echo “If you now running mysql and others commands,Please running: source /etc/profile”

脚本执行完,记得mysql_secure_installation 初始化数据库

文章来源: zmedu.blog.csdn.net,作者:互联网老辛,版权归原作者所有,如需转载,请联系作者。

原文链接:zmedu.blog.csdn.net/article/details/68486548

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。