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】
边栏推荐
- Missing number
- Open source | Wenxin big model Ernie tiny lightweight technology, which is accurate and fast, and the effect is fully open
- [reading notes] phased summary of writing reading notes
- 关于Unity屏幕相关Screen的练习题目,Unity内部环绕某点做运动
- collections. What is the purpose of chainmap- What is the purpose of collections. ChainMap?
- 微信小程序获取某个元素的信息(高、宽等),并将px转换为rpx。
- Pageoffice - bug modification journey
- Feature Engineering: summary of common feature transformation methods
- Markdown使用教程
- AcWing_ 188. Warrior cattle_ bfs
猜你喜欢

监控容器运行时工具Falco

開源了 | 文心大模型ERNIE-Tiny輕量化技術,又准又快,效果全開

来自数砖大佬的 130页 PPT 深入介绍 Apache Spark 3.2 & 3.3 新功能

Bigder: how to deal with the bugs found in the 32/100 test if they are not bugs

Bigder:32/100 测试发现的bug开发认为不是bug怎么处理

带角度的检测框 | 校准的深度特征用于目标检测(附实现源码)

Angled detection frame | calibrated depth feature for target detection (with implementation source code)

Interface difference test - diffy tool

Xcode real machine debugging

Install docker and use docker to install MySQL
随机推荐
NC24325 [USACO 2012 Mar S]Flowerpot
Multiprocess programming (V): semaphores
MySQL 23道经典面试吊打面试官
redis21道经典面试题,极限拉扯面试官
Multiprocess programming (4): shared memory
毕业总结
How do educators find foreign language references?
JSON转换工具类
免费自媒体必备工具分享
helm 基础学习
Digital twin visualization solution digital twin visualization 3D platform
详解用OpenCV的轮廓检测函数findContours()得到的轮廓拓扑结构(hiararchy)矩阵的意义、以及怎样用轮廓拓扑结构矩阵绘制轮廓拓扑结构图
[shutter] open the third-party shutter project
[MCU project training] eight way answering machine
Interface difference test - diffy tool
Don't want teachers to see themselves with cameras in online classes? Virtual camera you deserve!
開源了 | 文心大模型ERNIE-Tiny輕量化技術,又准又快,效果全開
Which software can translate an English paper in its entirety?
CMake基本使用
Analyze ad654: Marketing Analytics