linux centOS7.3 离线安装 mysql8

1、解压
tar xvf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar 
2、安装
rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-devel-8.0.18-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-compat-8.0.18-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm --force --nodeps
3、修改配置
#添加如下配置:
#只有在安装完成之后,初始化数据库之前,修改my.cnf,然后再初始化数据库才有效
#如果你不在意数据的话直接删除数据
#1 停止MySQL
#2 删除 MySQL的数据  /var/lib/mysql
#3 修改该   lower_case_table_names = 1
#4 启动 mysql
lower_case_table_names = 1
default_authentication_plugin=mysql_native_password

systemctl status mysqld.service

4、获取初始密码登录mysql

mysql在安装后会创建一个root@locahost账户,并且把初始的密码放到了/var/log/mysqld.log文件中;

cat /var/log/mysqld.log | grep password
或
grep 'temporary password' /var/log/mysqld.log

使用初始密码登录mysql ,四个密码最后一个是登陆密码

mysql -u root -p 

修改初始密码:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Liupsh@123';

FLUSH PRIVILEGES;
ps:创建用户并授权
CREATE USER 'root'@'%' IDENTIFIED BY 'Liupsh@123'; 

CREATE USER 'iam'@'%' IDENTIFIED BY 'Liupsh@123'; 

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' ;

GRANT ALL PRIVILEGES ON *.* TO 'iam'@'%' ;

FLUSH PRIVILEGES;
 

删除:

https://www.cnblogs.com/gaogaoyanjiu/p/9609923.html

 

 

你可能感兴趣的:(Linux)