mysql 数据库忘记密码

大家好今天,整理一下mysql进入安全模式

因为出了好多错误,也和大家说一下

1.首先要先关闭mysql

killall -9 mysqld 这个命令是关闭所有的mysqld的进程
systemctl stop mysqld 这个命令是关闭mysqld进程

2.开启mysql安全模式,以安全模式登录

mysql_safe --skip-grant-tables & 这个命令要注意,我在网上查了好多资料,都是这个命令但是执行就会报错

[root@iZuf63tzd3n3bigldlyfnpZ bin]# mysql_safe --skip-grant-tables &
[1] 5604
[root@iZuf63tzd3n3bigldlyfnpZ bin]# -bash: mysql_safe: command not found
^C
[1]+  Exit 127                mysql_safe --skip-grant-tables

它报错找不到 mysql_safe 这个命令,我以为这个命令要下载,经过查阅资料发现,这是mysql自带的命令
路径不对所以给它加了一个软连接

ln -s /usr/local/mysql/bin/mysqld_safe /usr/bin

有时候他会报错:因为他已经有在bin目录下边

3.执行命令

一定要看清楚命令,第一次报错就是因为命令写错了

mysqld_safe --skip-grant-tables &

如果报错就进入bin目录下执行

[root@iZuf63tzd3n3bigldlyfnpZ bin]# pwd
/usr/bin
[root@iZuf63tzd3n3bigldlyfnpZ bin]# mysqld_safe --skip-grant-tables &
[1] 5619
[root@iZuf63tzd3n3bigldlyfnpZ bin]# 210728 11:51:20 mysqld_safe Logging to '/usr/local/mysql/var/iZuf63tzd3n3bigldlyfnpZ.err'.
210728 11:51:20 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
#这里直接回车

这是代表你已经执行成功了

[root@iZuf63tzd3n3bigldlyfnpZ bin]# mysql -uroot -p
Enter password: #这里直接按回车就行了
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.62-log Source distribution

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

仔细的去看命令能节省好多时间,如果没看出来我错在哪里:我标一下

mysqld_safe 这个命令和 mysql_safe 这个少了一个d让我研究半天,mysqld_safe这个命令是对的

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值