Linux安装mysql8.0 ACE版本

在这里遇到的问题 

1.对应的linux7.0版本需要对应相应的sql版本   mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz

2.大文件上传推荐sftp,推流速度快

3.

-------------------------------------------------------分界线---------------------------------------------------------

#!/bin/sh
"#2019/01/07 update : 更新mysql版本为8.0.13,常规更新."
"#2019/10/23 update : 更新mysql版本为8.0.18,修复提权漏洞."

kirinenv="$1"

rpm -e --nodeps mysql-libs-5.1*

yum -y install cmake expect
yum -y install ncurses-devel
yum -y install bison
yum -y install git openssl-devel
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake bison git openssl-devel numactl.x86_64

dir3=`pwd`

tar -zxvf mysql-8.0.18-linux-glibc2.12-x86_64.tar.xz -C /usr/local/      
mv /usr/local/mysql-8.0.18-linux-glibc2.12-x86_64/ /usr/local/mysql
groupadd mysql
useradd -d /usr/local/mysql -g mysql -s /sbin/nologin mysql 
chown -R mysql:mysql /usr/local/mysql
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
mkdir -p /var/lib/mysql 
chown -R mysql:mysql /var/lib/mysql
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock 

ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /usr/local/mysql/lib/mysql /usr/lib64/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
ln -s /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk
ln -s /usr/local/mysql/bin/mysqld_safe /usr/bin/mysqld_safe

"cp etc/my.cnf /etc/my.cnf    #将已经写好的my.cnf配置文件放到/etc/my.cnf,先要把配置文件弄好再初始化,不然配置文件就不生效了"
cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld

cat > /etc/ld.so.conf.d/mysql.conf<<EOF
/usr/local/mysql/lib/mysql
/usr/local/lib
EOF
ldconfig

mkdir -p /data/mysql/data
chown -R mysql.mysql /data/mysql/data/

/usr/local/mysql/bin/mysqld --user=mysql --datadir=/data/mysql/data --initialize-insecure  #安装mysql
#/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data --initialize-insecure

chkconfig --level 35 mysqld on
/etc/init.d/mysqld restart
#后面关于登录密码的步骤就按https://blog.csdn.net/weixin_30545285/article/details/98486683这篇文章来处理
    1.编辑mysql配置文件:

vim /etc/my.cnf

  2.在pdi这行下边添加一行,并保存退出:

skip-grant-tables

  3.重启MySQL服务:

service mysqld restart 

  4.免密登录mysql,密码直接敲回车:

mysql -u root -p   或者mysql -h localhost -u root -p

  5.选择数据库:

use mysql;

  6.查看当前数据库信息,其中表中信息:

  host:允许用户登录的 ip ‘位置’ % 表示可以远程;

  user:登录数据库用户名;

  authentication:用户密码;(5.7.9以后不用password字段了,什么鬼,简单点不好吗?)

  plugin:加密方式;

"select host, user, authentication_string, plugin from user; "

  7.修改成我们需要的信息:(可以单独添加一个登录用户,或者直接在root上做文章)

"update user set host='%',plugin='mysql_native_password',authentication_string='' where user='root'; "

  8.退出mysql

quit

  9.删除 /etc/my.cnf 文件最后的 skip-grant-tables,保存并退出,并重启mysql服务

vim /etc/my.cnf
service mysqld restart

  10.重新登录到mysql,并修改密码(注意,上边如果把root的host改成了%,下边这里的localhost要写%)

mysql -u root -p
ALTER user 'root'@'localhost' IDENTIFIED BY 'Xpf123@';

ALTER user 'root'@'%' IDENTIFIED BY 'root';


-------------------------------------------------------------------------------------------------------

pass=`mkpasswd -l 18 -C 8 -s 0`  #生成随机密码

mysql -uroot -e "alter user root@'localhost'  identified by '$pass' password expire never;"
mysql -uroot -p$pass -e "flush privileges;"
mysql -uroot -p$pass -e "alter user root@'localhost' identified with mysql_native_password by '$pass';"
mysql -uroot -p$pass -e "create user root@'127.0.0.1' identified with mysql_native_password by '$pass';"
mysql -uroot -p$pass -e "grant all privileges on *.* to root@'127.0.0.1' with grant option;"
mysql -uroot -p$pass -e "create user root@'192.168.%' identified with mysql_native_password by '$pass';"
mysql -uroot -p$pass -e "grant all privileges on *.* to root@'192.168.%' with grant option;"
mysql -uroot -p$pass -e "create user root@'172.31.%' identified with mysql_native_password by '$pass';"
mysql -uroot -p$pass -e "grant all privileges on *.* to root@'172.31.%' with grant option;"
mysql -uroot -p$pass -e "create user root@'172.16.%' identified with mysql_native_password by '$pass';"
mysql -uroot -p$pass -e "grant all privileges on *.* to root@'172.16.%' with grant option;"
mysql -uroot -p$pass -e "create user root@'172.29.%' identified with mysql_native_password by '$pass';"
mysql -uroot -p$pass -e "grant all privileges on *.* to root@'172.29.%' with grant option;"


echo "数据库密码已设置为:$pass"

 

 

 

如果你觉得我的文章帮助到了你并节省了开发时间,请扫描下方二维码随意打赏❥(^_^)

您的支持是我最大的鼓励

 

 


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值