首页 > 编程知识 正文

linux下重置mysql密码,linux无密码登录mysql

时间:2023-05-06 06:23:20 阅读:19295 作者:1189

今天主要谈谈linux的mysql忘记密码的处理方法。 下面提供5种linux的mysql忘记密码恢复方法哦。

方法1 (先进入根权限) :

# /etc/init.d/mysql stop

# mysqld _ safe-- user=MySQL-- skip-grant-tables-- skip-networking

# mysql -u root

mysqlupdateusersetpassword=password (new password ) ) where user=‘root‘;

MySQL flush权限;

mysql quit

# /etc/init.d/mysql restart

# mysql -uroot -p

enter password:

mysql

方法2 :

直接使用/etc/mysql/debian.cnf文件的“客户端”部分中指定的用户名和密码:

# MySQL-u设备- sys-maint-p

enter password:

mysqlupdateusersetpassword=password (' new password ' ) where user=root;

MySQL flush权限;

mysql quit

# mysql -uroot -p

enter password:

mysql

方法3 :

我没有测试过这个方法。 root用户的默认密码已更改。 那个人有时间测试。 请告诉我结果。 谢谢你。

# mysql -uroot -p

enter password:

方法4 :

方法: 1、退出mysql服务/etc/init.d/mysqld stop 2,使用-skip-grant-tables选项启动mysql服务,然后单击/etc/inin.d/mysqld VI

方法如下。

1,退出mysql服务

/etc/init.d/mysqld stop

2,-使用-skip-grant-tables选项启动mysql服务后,可以更改/etc/inin.d/mysqld脚本的启动位置并添加此选项。

vi /etc/init.d/mysqld

将--skip-grant-tables添加到要执行启动的以下语句中

/usr/bin/mysqld _ safe-- skip-grant-tables-- datadir=' $ datadir '-- socket=' $ socket file '

- log-error=' $ errogfile '-- PID-file=' $ my pidfile '

加入--skip-grant-tables意味着在启动mysql服务时跳过权限表认证。 启动后,连接mysql的root不需要密码

3,重新启动mysql服务

/etc/init.d/mysqld start

更改根用户的密码

mysqlupdatemysql.userset password=password (123456 ) ) where user=root;

MySQL flush权限;

mysql quit

重新启动mysql后,可以使用新密码登录。

mysql

MySQL-u路由p

输入密码: 123456

6,退出mysql服务

/etc/init.d/mysqld stop

7、将步骤2中修改的/etc/init.d/mysqld保留原样,即修改为取消--skip-grant-tables语句

8,重新启动mysql服务

/etc/init.d/mysqld start

后记:

新安装的MySQL有密码,但实际上自动保存在某个文件夹中。 我正在安装MySQL-server-5.6.35-1.el6.x86 _ 64.rpm、rpm安装方法和MySQL根密码。 默认密码位于名为:/root/.mysql_secret的文件夹中。 ///我不能打开. SO . 忘记密码时,如何找回MySQL的初始根密码? 虽然找到的方法都是可行的,但唯一糟糕的是设置我的newpasswd版本时可能需要新密码

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。