Centos7安装MySQL8.0.25
上传rpm包  运行下面五行代码执行安装MySQL
rpm -ivh mysql-community-common-8.0.25-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.25-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.25-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.25-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.25-1.el7.x86_64.rpm
运行第三行指令时出现错误  运行下面指令,清楚之前安装过的依赖
yum remove mysql-libs
 然后再执行第三行指令就不会报错了 
检查是否成功
查看版本
mysql --version

查看安装的MySQL
rpm -qa | grep -i mysql

初始化MySQL
服务的初始化
mysqld --initialize --user=mysql
说明: --initialize 选项默认以“安全”模式来初始化,则会为 root 用户生成一个密码并将 该密码标记为过 期 ,登录后你需要设置一个新的密码。生成的 临时密码 会往日志中记录一份。
查看MySQL临时密码
cat /var/log/mysqld.log

启动MySQL
启动:systemctl start mysqld.service
关闭:systemctl stop mysqld.service
重启:systemctl restart mysqld.service
查看状态:systemctl status mysqld.service

登录MySQL
执行命令后确认,然后输入临时密码
mysql -uroot -p

修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
远程连接MySQL
关闭防火墙/开放相应端口
关闭防火墙
systemctl start firewalld.service
systemctl status firewalld.service
systemctl stop firewalld.service
#设置开机启用防火墙
systemctl enable firewalld.service
#设置开机禁用防火墙
systemctl disable firewalld.service
开放相应端口
查看开放的端口号
firewall-cmd --list-all
设置开放的端口号
firewall-cmd --add-service=http --permanent
firewall-cmd --add-port=3306/tcp --permanent
重启防火墙
firewall-cmd --reload
修改任意IP都能远程连接MySQL
use mysql;
// % 是通配符,表示任意IP都能连接MySQL
update user set host = '%' where user ='root';
// 修改密码加密方法
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';
// 使配置立即生效
flush privileges;
使用sqlyog远程连接MySQL

|