如果添加了MySQL的环境变量,则可以直接运行mysql有关命令,否则必须到mysql安装目录的bin目录下操作。 步骤如下: 1.停止mysql服务(以管理员身份,在cmd命令行下运行) net stop mysql 2.使用 mysqld –skip-grant-tables 命令启动mysql数据库 D:\net stop mysql MySQL 服务正在停止. MySQL 服务已成功停止。 D:\mysqld --skip-grant-tables 3.不关闭以上窗口,新开一个cmd窗口,输入mysql -u root,直接按回车键 D:\mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.26-rc-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql update mysql.user set password=password('aaa') where user='root'; 密码可以自己随便写。 Query OK, 1 row affected (0.02 sec) Rows matched: 2 Changed: 1 Warnings: 0 mysql flush privileges; Query OK, 0 rows affected (0.00 sec) mysql 4.打开任务管理器,停止mysql,mysqld进程,使用net start mysql启动mysqld服务,就可以使用root用户 root密码进入数据库了 mysql -u root -p aaa
2.打开命令行,转到mysql的bin目录下; 复制代码代码如下: C:\Users\Administratorcd C:\Program Files\MySQL\MySQL Server 5.5\bin C:\Program Files\MySQL\MySQL Server 5.5\bin
3.输入:mysqld -nt --skip-grant-tables 然后回车,如果没有错误信息,就行了;注:skip-grant-tables参数用了之后,就可以跳过登录校验; 复制代码代码如下: C:\Program Files\MySQL\MySQL Server 5.5\binmysqld -nt --skip-grant-tables140317 13:23:11 [Warning] option 'new': boolean value 't' wasn't recognized. Set to OFF.
4.再打开一个命令行(因为刚才那个DOS窗口已经不能动了),同样转到mysql的bin目录下; 5.直接输入 mysql 并回车,如果成功,将出现MySQL提示符 复制代码代码如下: C:\Users\Administratorcd C:\Program Files\MySQL\MySQL Server 5.5\bin
C:\Program Files\MySQL\MySQL Server 5.5\binmysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.5.35 MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql 6.切换到mysql表 复制代码代码如下: mysqlUSE mysql; 7.可以修改密码了: 复制代码代码如下: UPDATE user SET password=PASSWORD(123456) WHERE user=root; 8.刷新权限,不要忘记了: 复制代码代码如下: mysqlFLUSH PRIVILEGES; 9.退出:(退出的方法很多 有quit、exit、ctrl+c、\q 等等); 10.注销或重启计算机,然后打开MySQL服务,使用用户名root和设置的新密码就可以登录了。
如果添加了MySQL的环境变量,则可以直接运行mysql有关命令,否则必须到mysql安装目录的bin目录下操作。步骤如下: 1.停止mysql服务(以管理员身份,在cmd命令行下运行) net stop mysql 2.使用 mysqld –skip-grant-tables 命令启动mysql数据库 D:\net stop mysql MySQL 服务正在停止. MySQL 服务已成功停止。 D:\mysqld --skip-grant-tables 3.不关闭以上窗口,新开一个cmd窗口,输入mysql -u root,直接按回车键