1打開mysql.exe和mysqld.exe所在的文件夾,複製路徑地址mysql
輸入命令 mysqld --skip-grant-tables 回車,此時就跳過了mysql的用戶驗證。注意輸入此命令以後命令行就沒法操做了,此時能夠再打開一個新的命令行。注意:在輸入此命令以前先在任務管理器中結束mysqld.exe進程,確保mysql服務器端已結束運行。sql
輸入mysql登錄服務器
1 C:\Users\Administrator>mysql 2 Welcome to the MySQL monitor. Commands end with ; or \g. 3 Your MySQL connection id is 3 4 Server version: 5.5.40 MySQL Community Server (GPL) 5 Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 6 Oracle is a registered trademark of Oracle Corporation and/or its 7 affiliates. Other names may be trademarks of their respective 8 owners. 9 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 10 mysql>
1 mysql> show databases; 2 +--------------------+ 3 | Database | 4 +--------------------+ 5 | information_schema | 6 | itcastoa0720 | 7 | kingoa | 8 | mysql | 9 | performance_schema | 10 | qin | 11 | student | 12 | test | 13 +--------------------+ 14 8 rows in set (0.01 sec) 15 16 mysql> use mysql 17 Database changed 18 mysql> show tables; 19 +---------------------------+ 20 | Tables_in_mysql | 21 +---------------------------+ 22 | columns_priv | 23 | db | 24 | event | 25 | func | 26 | general_log | 27 | help_category | 28 | help_keyword | 29 | help_relation | 30 | help_topic | 31 | host | 32 | ndb_binlog_index | 33 | plugin | 34 | proc | 35 | procs_priv | 36 | proxies_priv | 37 | servers | 38 | slow_log | 39 | tables_priv | 40 | time_zone | 41 | time_zone_leap_second | 42 | time_zone_name | 43 | time_zone_transition | 44 | time_zone_transition_type | 45 | user | 46 +---------------------------+ 47 24 rows in set (0.01 sec) 48 49 mysql> select user,host,password from user; 50 +------+-----------+-------------------------------------------+ 51 | user | host | password | 52 +------+-----------+-------------------------------------------+ 53 | root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | 54 +------+-----------+-------------------------------------------+ 55 1 row in set (0.00 sec) 56 57 mysql> update user set password=password('123456') where user='root' and host='l 58 ocalhost'; 59 Query OK, 1 row affected (0.00 sec) 60 Rows matched: 1 Changed: 1 Warnings: 0 61 62 mysql> select user,host,password from user; 63 +------+-----------+-------------------------------------------+ 64 | user | host | password | 65 +------+-----------+-------------------------------------------+ 66 | root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | 67 +------+-----------+-------------------------------------------+ 68 1 row in set (0.00 sec) 69 70 mysql>
從新打開一個cmd命令窗口,測試測試
1 C:\Users\Administrator>mysql -u root -p123456 2 Welcome to the MySQL monitor. Commands end with ; or \g. 3 Your MySQL connection id is 7 4 Server version: 5.5.40 MySQL Community Server (GPL) 5 6 Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 7 8 Oracle is a registered trademark of Oracle Corporation and/or its 9 affiliates. Other names may be trademarks of their respective 10 owners. 11 12 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 13 14 mysql>