- 在mysql官网下载mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
- 查看是否已经安装了mysql rpm -qa |grep mysql
rpm -qa | grep mysql
- 查看是否已经安装了mariadb
rpm -qa | grep mariadb
[root@bogon software]# rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
卸载mariadb
- rpm -e --nodeps mariadb-libs
按顺序安装mysql
- rpm -ivh mysql-community-common-8.0.28-1.el7.x86_64.rpm 安装通用包
- rpm -ivh mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm 安装客户端插件
- rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm 安装依赖lib包
- rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm 安装客户端
- rpm -ivh mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm 安装icu-data
- rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm 安装服务端,但是报错误没需要安装net-tools
- 警告:mysql-community-server-8.0.28-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
错误:依赖检测失败:
net-tools 被 mysql-community-server-8.0.28-1.el7.x86_64 需要
- yum install net-tools
- 再次安装server
rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm
- 初始化mysql
mysqld --initialize --console
- 改变权限
chown -R mysql:mysql /var/lib/mysql/
- 启动mysql
systemctl start mysqld
- 查看mysql初始化时候的密码
cat /var/log/mysqld.log
cat /var/log/mysqld.log |grep localhost
- 登录mysql
Mysql -uroot -p
- 修改密码
alter user 'root'@'localhost' IDENTIFIED BY '
修改root密码
alter user 'root'@'localhost' IDENTIFIED BY 'roottest001';
flush privileges;
8)重新登陆
9)ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'roottest001';(修改root密码)
10)创建数据库,带编码格式;
create database mydb1 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
create database xiaozhu DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
11)创建用户
create user 'test'@'192.168.%' identified by 'test002' PASSWORD EXPIRE NEVER;
ALTER USER 'test'@'192.168.%' IDENTIFIED WITH mysql_native_password BY 'test002';
GRANT ALL ON test.* TO 'mydb1'@'192.168.%';
- 开启防火墙
systemctl status firewalld 查看防火墙状态
systemctl stop firewalld 关闭防火墙
system enable firewalld 启动防火墙
systemctl disable firewalld 禁用防火墙
systemctl status firewalld 开启防火墙
firewall-cmd --zone=public --list-ports 查看防火墙列表
firewall-cmd --add-port=3306/tcp --permanent (设置3306端口开启,永久)
firewall-cmd --reload 重新加载
firewall-cmd --zone=public --list-ports
3306/tcp