linux安装MySQL
①.下载MySQL的YUM仓库文件
下载地址:http://dev.mysql.com/downlodes/repo/yum/
【根据自己虚拟机版本下载】
②.通过xftp将下载的文件传到linux
③.用yum命令安装xftp传过来的文件
yum install mysql8-community-release-el7-11.noarch.rpm
④.yum install mysql-community-server
对于GPG验证问题,加下边一句
rpm --import http://repo.mysql.com/RPM-KEY-mysql-2022
⑤.启动服务
systemctl start mysqld
⑥.查看默认密码
cat /var/log/mysqld.log | grep password
⑦.登录MySQL
mysql -u root -p 【密码是上边的默认密码】
⑧.修改密码
update user set password = password() where user = ‘root’;
flush privileges;
⑨.远程登陆
1.修改加密方式
alter user root@’%’ identified by ‘密码’ password expire never;
2.修改密码
alter user root@’%’ identified with mysql_native_password by ‘密码’;
3.刷新权限
flush privileges;
–
新用户远程登陆
创建用户并设置密码
create user newusername@’%’ identified by ‘密码’;
修改加密方式
alter user newusernamet@’%’ identified with mysql_native_password by ‘密码’
授权远程连接
grant all privileges on . to newusername@’%’ with grant option;