function install_mysql(){
MYSQL_BASE=/usr/local/mysql
cd $TMP_DIR
file="mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz"
if [ ! -f $file ]; then
echo "File not found!"
yum install -y wget && wget -c wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz;
echo " Download complete , Decompressing .......";
tar -zxvf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.37-linux-glibc2.12-x86_64 /usr/local/mysql
cd /usr/local/mysql
#exit 0
fi
echo " Create user group "
userdel mysql;
groupadd mysql;
useradd -r -g mysql mysql;
mkdir -p /data/mysql;
chown mysql:mysql -R /data/mysql;
cd /etc
echo " Write to configuration file "
cat > my.cnf <<EOF
[mysqld]
bind-address=0.0.0.0 # Bind address to run remote connection
port=3306 #Mysql Open port
user=mysql # Database login user
basedir=/usr/local/mysql #Mysql The absolute path of the installation
datadir=/data/mysql #Mysql The absolute path of data storage
socket=/tmp/mysql.sock # Socket file
log-error=/data/mysql/mysql.err #mysql The path where the generated error log is stored
pid-file=/data/mysql/mysql.pid # by mysqld The program specifies a storage process ID The file of
character_set_server=utf8mb4 # Database character coding
symbolic-links=0 # Whether to turn on the link symbol
explicit_defaults_for_timestamp=true # database timestamp Columns of type are automatically updated
EOF
echo " initialization Mysql"
cd /usr/local/mysql/bin/
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize
sleep 2s
ehco " start-up mysql"
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
service mysql start
service mysql status
ln -s /usr/local/mysql/bin/mysql /usr/bin
echo " obtain mysql Initial password "
PASSWORD=`cat /data/mysql/mysql.err |grep "temporary password"|awk -F"[email protected]: " '{print $2}'`
echo " modify mysql password "
$MYSQL_BASE/bin/mysql --socket=/tmp/mysql.sock --connect-expired-password -uroot -p${PASSWORD} -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '[email protected]';"
$MYSQL_BASE/bin/mysql --socket=/tmp/mysql.sock -uroot [email protected] -e "FLUSH PRIVILEGES;"
$MYSQL_BASE/bin/mysql --socket=/tmp/mysql.sock -uroot [email protected] -e "USE mysql;"
$MYSQL_BASE/bin/mysql --socket=/tmp/mysql.sock -uroot [email protected] -e "UPDATE user SET host = '%' WHERE user = 'root';"
$MYSQL_BASE/bin/mysql --socket=/tmp/mysql.sock -uroot [email protected] -e "FLUSH PRIVILEGES;"
$MYSQL_BASE/bin/mysql --socket=/tmp/mysql.sock -uroot [email protected] -e "exit;"
echo " Restart the database "
service mysql restart;
service mysql status;
echo " Start with a service item "
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld;
chmod +x /etc/init.d/mysqld;
chkconfig --add mysqld;
chkconfig --list;
firewall-cmd --zone=public --add-port=3306/tcp --permanent;
firewall-cmd --reload;
firewall-cmd --list-all;
echo "=========> MYSQL Information <========="
echo " Database version : 5.7.37 "
echo " Database password : [email protected] "
echo " Database port : 3306 "
echo " BASEDIR Catalog : /usr/local/mysql "
echo " DATADIR Catalog : /data/mysql "
}
install_mysql
当前位置:网站首页>Centos7 one click compilation to build MySQL script
Centos7 one click compilation to build MySQL script
2022-07-03 00:25:00 【KentBryce】
边栏推荐
猜你喜欢
MySQL advanced learning notes (III)
ftrace工具的介绍及使用
Seckill system design
Chinatelecom has maintained a strong momentum in the mobile phone user market, but China Mobile has opened a new track
開源了 | 文心大模型ERNIE-Tiny輕量化技術,又准又快,效果全開
Digital twin smart factory develops digital twin factory solutions
Multiprocess programming (I): basic concepts
DotNet圈里一个优秀的ORM——FreeSql
洛谷_P1149 [NOIP2008 提高组] 火柴棒等式_枚举打表
Explain in detail the significance of the contour topology matrix obtained by using the contour detection function findcontours() of OpenCV, and how to draw the contour topology map with the contour t
随机推荐
開源了 | 文心大模型ERNIE-Tiny輕量化技術,又准又快,效果全開
LeedCode1480. Dynamic sum of one-dimensional array
Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation
Markdown使用教程
How to write the design scheme of the thesis?
Using tensorflow to realize voiceprint recognition
多进程编程(二):管道
Bypass AV with golang
Go自定义排序
可下载《2022年中国数字化办公市场研究报告》详解1768亿元市场
多进程编程(三):消息队列
Basic 10 of C language: array and pointer
Seckill system design
NC24840 [USACO 2009 Mar S]Look Up
Chinatelecom has maintained a strong momentum in the mobile phone user market, but China Mobile has opened a new track
Open source | Wenxin big model Ernie tiny lightweight technology, which is accurate and fast, and the effect is fully open
Hit the industry directly! The propeller launched the industry's first model selection tool
洛谷_P1149 [NOIP2008 提高组] 火柴棒等式_枚举打表
LeedCode1480.一维数组的动态和
哪些软件可以整篇翻译英文论文?