linux安装mysql时使用临时密码登录不进去mysql: [Warning] Using a password on the command line interface can be insec

1.在root用户下,停止mysql

service mysqld stop

2.vi /etc/my.cnf

在[mysqld]的段中加上一句skip-grant-tables 

[mysqld]

skip-grant-tables 

shift+z+z;保存退出

3.重新启动mysql

systemctl start mysqld

3.登录修改mysql 的密码

[root@python2 hadoop]# mysql -uroot -p

Enter password: 

一直敲回车

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2

Server version: 5.7.21 MySQL Community Server (GPL)

看到welcome登录成功

5.FLUSH PRIVILEGES;  执行这条命令刷新

6.授权

mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION; 

Query OK, 0 rows affected, 1 warning (0.01 sec)

6:修改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

Query OK, 0 rows affected (0.00 sec)

7.退出  quit;

8. 到vi /etc/my.cnf 删除skip-grant-tables 

7.登录mysql 成功修改密码并登录

  • 8
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值