删除原有mariadb
[root@test mysql]# rpm -qa | grep mariadb
mariadb-devel-5.5.52-1.axs7.x86_64
mariadb-libs-5.5.52-1.axs7.x86_64
[root@test mysql]# rpm -e --nodeps mariadb-libs-5.5.52-1.axs7.x86_64
[root@test mysql]# rpm -qa | grep mariadb
mariadb-devel-5.5.52-1.axs7.x86_64
[root@test mysql]# rpm -e --nodeps mariadb-devel-5.5.52-1.axs7.x86_6
安装rpm包
rpm -ivh mysql-community-client-plugins-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-embedded-compat-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-test-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-8.0.26-1.el7.x86_64.rpm
标题启动MySQL 查看初始密码
systemctl start mysqld
# 查看mysql 状态
systemctl status mysqld
cat /var/log/mysqld.log | grep password
2021-08-02T02:53:22.066347Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Rk)fZFq%+7ru
修改默认密码
use mysql;
alter USER 'root'@'localhost' identified with mysql_native_password by 'DqyG89GwUjm1vR0oUqhH@';
开启远程登录
update user set host='%' where user = 'root';
flush privileges ;
创建子用户
use mysql;
CREATE USER 'pfpj'@'%' IDENTIFIED BY 'DqyG89GwUjm1vR0oUqhH@';
GRANT ALL ON *.* TO 'pfpj'@'%';
flush privileges ;
-- 验证
开机启动
systemctl enable mysqld
#取消开机启动
systemctl disable mysqld
netstat -ntlp | grep mysql
数据初始化
use nmggzhhz;
source /app/mysql/nmggzhhz.sql;
show tables ;
select * from t_bank_enterprise_balance ;