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】
边栏推荐
- Is there a specific format for English papers?
- Monitor container runtime tool Falco
- Where can I find foreign papers?
- Nc20806 District interval
- 1380. Lucky numbers in the matrix
- Pytorch 20 realizes corrosion expansion based on pytorch
- 论文的设计方案咋写?
- Pytorch里面多任务Loss是加起来还是分别backward?
- Feature Engineering: summary of common feature transformation methods
- 程序分析与优化 - 9 附录 XLA的缓冲区指派
猜你喜欢
Is the multitasking loss in pytoch added up or backward separately?
Cmake basic use
监控容器运行时工具Falco
多进程编程(一):基本概念
Basic 10 of C language: array and pointer
Digital collection trading website domestic digital collection trading platform
Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation
redis21道经典面试题,极限拉扯面试官
Luogu_ P2010 [noip2016 popularization group] reply date_ Half enumeration
Architecture: database architecture design
随机推荐
Sysdig analysis container system call
布隆过滤器
ftrace工具的介绍及使用
node_modules删不掉
Implement the foreach method of array
毕业总结
How to specify const array in the global scope of rust- How to specify const array in global scope in Rust?
Define MySQL function to realize multi module call
zhvoice
Program analysis and Optimization - 9 appendix XLA buffer assignment
Multiprocess programming (4): shared memory
Chapter 3 of getting started with MySQL: database creation and operation
Pytorch 20 realizes corrosion expansion based on pytorch
sysdig分析容器系统调用
Luogu_ P1149 [noip2008 improvement group] matchstick equation_ Enumeration and tabulation
论文的英文文献在哪找(除了知网)?
TypeError: Cannot read properties of undefined (reading ***)
Bloom filter
Go custom sort
有哪些比较推荐的论文翻译软件?