MySql 安装
Yum安装MySql
1. 下载MySQL rpm文件
我选择安装MySQL 8.0 版本,官网下载地址
这里我选择的是 Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package
如果不知道该下载哪个版本的小伙伴,可以先查看一下本地Linux的版本
-uanem -a
安装步骤
- 把下载好的rpm文件上传至服务器,然后找到上传目录,进行安装
安装rpm文件
rpm -ivh mysql80-community-release-el7-11.noarch.rpm
安装完成后进行,Yum下载
yum install mysql-community-server
2. 查看当前mysql
rpm -qa | grep mysql
- 启动mysql
systemctl start mysqld
systemctl status mysqld
- 重置MySql密码
目前版本mysql有初始化默认密码 查看密码
# 先尝试寻找mysqld.log文件
find / -name mysqld.log
# 找到后查看默认密码
grep 'temporary password' /var/log/mysqld.log
# 2023-11-30T04:55:19.374225Z 6 [Note] [MY-010454] [Server]
#A temporary password is generated for root@localhost: d;By?q!Ap1qp
# root@localhost:后面就是默认密码
# 重置密码
mysql_secure_installation
# The existing password for the user account root has expired. Please set a new password.
# New password:
# Re-enter new password:
# 登录验证
mysql -u root -p
- 设置外网可以访问
在mysql的bin目录下执行:mysql -u root -p密码 登陆到数据:
select host from mysql.user where user='root';
update mysql.user set host='%' where user='root';
flush privileges; #刷新配置
exit;
教程到这里完成了,如果有感觉教程步骤有问题,欢迎各位小伙伴提出修改指导。