linux环境下shell一键安装mysql5.7.19(简单暴力)

#!/bin/bash
cd /ijiami/soft/
tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql
mv mysql /ijiami
groupadd mysql
useradd -r -g mysql mysql
chown -R mysql:mysql ./
mv /etc/my.cnf /etc/my.cnf.bak
cp /ijiami/soft/my.cnf /etc/my.cnf
mkdir -p /ijiami/mysql/data
cd /ijiami/mysql/
bin/mysqld --initialize --user=mysql --basedir=/ijiami/mysql/ --datadir=/ijiami/mysql/data/ 2>&1 | tee >/home/mysql.log
chown -R root:root ./
chown -R mysql:mysql data
cp support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig --level 2345 mysql on
ln -s /ijiami/mysql/bin/mysqladmin /usr/sbin
ln -s /ijiami/mysql/bin/mysql /usr/sbin
service mysql start
echo "---------mysql已经安装启动成功-----------"
#cat /home/mysql.log | grep 'temporary password' | awk '{print $NF}'
temppasswd=$(cat /home/mysql.log | grep 'temporary password' | awk '{print $NF}')
echo "----mysql已经安装成功,请在/home/mysql.log查看安装日志详情---------"
mysql -uroot -p${temppasswd} --connect-expired-password <SET PASSWORD = PASSWORD('ijiamidbroot');
flush privileges;
use mysql;
update user set host = '%' where user = '127.0.0.1';
grant all privileges on *.* to root@'%' identified by 'ijiamidbroot';
flush privileges;
EOF

转载于:https://www.cnblogs.com/xinsfree/p/10990966.html

你可能感兴趣的:(linux环境下shell一键安装mysql5.7.19(简单暴力))