1. mysql Linux环境的安装
## 1.下载 mysql
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.30-el7-x86_64.tar.gz
## 2.解压
tar -zxvf mysql-8.0.30-el7-x86_64.tar.gz
## 3. 将文件改个名字方便识别
mv mysql-8.0.30-el7-x86_64 mysql8
## 4.创建组
groupadd mysql
## 5.创建组用户 nikaboy
useradd -g mysql nikaboy
chown -R nikaboy:mysql /nikaboy/mysql8
## 6.编辑my.cnf 文件
vim /etc/my.cnf
## 7. 初始化 获得初始密码 ([Server] A temporary password is generated for root@localhost: s1j:ff<Cl#-g)
cd /nikaboy/mysql8/bin/
./mysqld --initialize
## 8.添加mysqld服务到系统,开机自动启动
cd /nikaboy/mysql8
cp -a ./support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
## 9.启动mysql
service mysql start
##10 登录用户 此时会出现(bash mysql:未找到)
mysql -uroot -p
#映射 /nikaboy/mysql8/bin/mysql 为自己mysql的bin目录下
ln -s /nikaboy/mysql8/bin/mysql /usr/bin
## 11.重新登录,使用初始化密码登录
mysql -uroot -p
## 12.修改密码, 123456 是设置的密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
flush privileges; -- 刷新
## 13. 更改root连接权限
use mysql;
update user set host='%' where user = 'root';
flush privileges;
exit;
## 14. 重新登录
mysql -uroot -p
my.cnf文件
<