long blogs

进一步有进一步惊喜


  • Home
  • Archive
  • Tags
  •  

© 2025 long

Theme Typography by Makito

Proudly published with Hexo

linux安装MySql

Posted at 2019-07-15 笔记 mysql 

转载来的哦!!

yum安装

介绍Linux下使用Yum安装Mysql:

  1. 在mysql官网下载mysql的yum源
1
wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
  1. 上传到centos中并执行本地安装
1
yum localinstall mysql80-community-release-el7-3.noarch.rpm
  1. 安装服务
1
yum -y install mysql-community-server
  1. 查看Mysql服务的状态
1
service mysqld status
  1. 开启Mysql服务
1
service mysqld start
  1. 查看配置文件,找到日志目录
1
vim /etc/my.cnf
  1. 查看日志文件,找到初始密码
1
vim /var/log/mysqld.log
  1. 登录MySQL
1
mysql -u root -p
  1. 修改初始密码(Root.123)大小写字母加数字加符号
1
alter user 'root'@'localhost' identified by 'Root.123';
远程授权

授权远程登录账号:

  1. 以下是5.7版本的方法,实测在8.0以上版本不行
  • 第一个xxxx是用户名,第二个xxxx是密码,意思是通过xxxx用户和密码可以从任何主机连接到mysql服务器。
1
2
grant all privileges on *.* to 'xxxx'@'%' identified by 'xxxxxx' with grant option;
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
  • 权限立即生效
1
flush privileges;
  1. 以下是适用于8.0版本的授权:
  • 进入数据库
1
use mysql;
  • 查看当前用户信息
1
select host, user, authentication_string, plugin from user;
  • 修改MySQL对密码的要求
1
2
set global validate_password.policy=0;
set global validate_password.length=1;
  • 创建远程连接的用户
1
2
// 模板 create user 'xxxx'@'x' identified by 'xxxxxxx';
create user 'kang'@'%' identified by 'kang123';
  • 修改密码加密规则,mysql8.0默认的加密方式是“caching_sha2_password”,而navicat只支持以前的”mysql_native_password”
1
ALTER USER 'kang'@'%' IDENTIFIED WITH mysql_native_password BY 'kang123';
  • 查看加密规则是否改变
1
select host, user, authentication_string, plugin from user;
  • 给新用户添加权限,最后刷新权限。
    *.*说明。前一个是数据库名称,后一个是表名称。
1
2
GRANT ALL PRIVILEGES ON *.* TO 'kang'@'%';
flush privileges;

Share 

 Previous post: linux环境配置 Next post: spring笔记 

© 2025 long

Theme Typography by Makito

Proudly published with Hexo