9

MySQL初始化root密码以及root密码忘记解决方法

 4 years ago
source link: https://xushanxiang.com/2019/07/mysql-initializes-the-root-password.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

MySQL初始化root密码以及root密码忘记解决方法

作者: xusx 分类: MySQL 发布时间: 2019-07-31 22:00

一、MySQL初始化root密码

mysql默认root用户没有密码,输入mysql –u root 进入mysql

1、进入mysql数据库

use mysql;

2、初始化root密码

mysql>update user set password=PASSWORD('123456') where User='root';

(补充:授权请戳这里

二、root密码忘记解决方法(Windows环境)

1、确保MySQL服务停止

例如,在DOS窗口下输入 net stop mysql5 或 net stop mysql

2、打开第一个cmd窗口,进入MySQL安装目录下的bin目录

例如,D:\mysql-5.5.35-win32\bin>

3、跳过权限安全检查,MySQL服务运行起来后,不用输入密码就能进入数据库

例如,D:\mysql-5.5.35-win32\bin>mysqld –defaults-file=”D:\mysql-5.5.35-win32\my.ini” –console –skip-grant-tables

4、打开第二个cmd窗口,连接MySQL

输入命令:mysql -uroot -p

出现 Enter password: 直接回车

5、使用命令切换到mysql数据库:

use mysql;

6、使用命令更改root密码:

UPDATE user SET Password=PASSWORD('在此输入新密码') where USER='root';

7、刷新权限:

FLUSH PRIVILEGES;

8、退出:

quit;

9、关闭上面打开的两个cmd窗口,重新启动MySQL服务。

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!

发表评论 取消回复

电子邮件地址不会被公开。 必填项已用*标注


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK