centos7安装mysql8

#进入目录,没有就建一个
cd /usr/local/mysql
#下载源
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
#安装源
rpm -ivh mysql80-community-release-el7-3.noarch.rpm
#GPG更新
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
#安装mysql
yum install mysql-server
#启动mysql
systemctl start mysqld
#自动启动mysql
systemctl enable mysqld
#查看状态mysql
systemctl status mysqld


编辑 /etc/my.cnf 新增

[mysqld]
binlog_format=row
log-bin=mysql-bin
#重启mysql
systemctl restart mysqld

#查看密码mysql
cat /var/log/mysqld.log| grep password

#登录
mysql -uroot -p

#修改密码
ALTER USER USER() IDENTIFIED BY '123456Admin@123';
ALTER USER USER() IDENTIFIED BY 'ASDqwe!@#123';
#授权其他ip访问
update mysql.user set host ="%" where user = "root";

#刷新权限
flush privileges;

#退出mysql

#打开防火墙,刷新
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports

你可能感兴趣的:(mysql)