1.下载rpm文件
-
下载网址为:
https://dev.mysql.com/downloads/repo/yum/
-
选择对应版本点击下载,也如页面后复制以下链接:
2.执行命令开始下载安装
- 1)下载命令:
wget 刚才复制的链接
- 例:
wget https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
- 2)安装命令:
rpm -ivh 下载的文件名
- 例:
rpm -ivh mysql80-community-release-el8-1.noarch.rpm
- 安装成功之后,会在/etc/yum.repos.d/文件夹下增加两个文件
- 安装mysql命令:
yum install mysql-community-server -y
,大概60多M,解压后300多M
3.启动Mysql服务
- 更新:
yum update -y
- 命令:
service mysqld start
- 查看状态命令:
service mysqld status
- 设置开机启动:
chkconfig mysqld on
- 获取临时密码:
grep "password" /var/log/mysqld.log
- 登录:
mysql -uroot -p
输入密码
4.修改密码,设置远程访问
>set global validate_password.policy=0;
>set global validate_password.length=1;
>ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘你的密码‘;
- 切换mysql表:
>use mysql;
>select user,authentication_string,host from user;
>update user set host = ‘%‘ where user = ‘root‘;