数据库初始化设置密码时报错“SET PASSWORD has no significance for user ‘root‘@‘localhost‘ as the authentication met

一、报错信息​

Re-enter new password: 
 ... Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.

如果一直卡在重复输入密码这一步,新建一个连接窗口,执行命令:

sudo killall -9 mysql_secure_installation

二、手动配置密码

进入mysql终端:

在mysql终端下修改密码:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '输入你的数据库密码';

然后exit,回到终端,重新开始初始化设置:

sudo mysql_secure_installation
  1. 初始化配置信息 sudo mysql_secure_installation

    • VALIDATE PASSWORD COMPONENT.....(使用密码强度校验组件) 输入: n
    • New Password:(设置新密码,并重复一遍)
    • Remove anonymous users (删除匿名用户) n
    • Disallow root login remotely(拒绝远程root账号登录) n
    • Remove test database and access to it(移除test数据库) n
    • Reload privilege tables now (现在就重新载入权限表) y

如果缺少文件:

​​​​

【注意路径】需重新下载:wget -O mysql.cnf.example http://exampleconfig.com/static/raw/mysql/ubuntu20.04/etc/mysql/mysql.cnf​​​

修改mysqld.cnf​​:

//1. 注释"bind-address = 127.0.0.1"

//2. 修改端口号
port = 4417

配置root用户外网访问:

​​

 

​​​​

//1. 登陆数据库
sudo mysql -u root -p

//2. 配置

//2.1 选择数据库
use mysql

//2.2 查看账号的主机权限
select user,host from user;

//2.3 host处为localhost时只允许本地使用,改成 % 即可远程使用
update user set host='%' where user='root';

//2.4 刷新缓存
flush privileges;

//2.5 退出mysql
exit;

//3. 重启服务
sudo service mysql restart

//如果需要关闭防火墙
sudo ufw status  //inactive为没开
sudo ufw allow 4417  //允许4417端口通过防火墙

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值