记录下解决mysql“Access denied for user 'root'@'localhost'”

[size=large][b]windows下:[/b][/size]

切换到MySQL/bin目录下
E:\wamp\bin\mysql\mysql5.6.12\bin>
mysqld --defaults-file="E:\wamp\bin\mysql\mysql5.6.12\my.ini" --console --skip-grant-tables


2015-01-22 14:01:34 0 [Warning] TIMESTAMP with implicit DEFAULT value is depreca
ted. Please use --explicit_defaults_for_timestamp server option (see documentati
on for more details).
2015-01-22 14:01:34 3700 [Note] Plugin 'FEDERATED' is disabled.
2015-01-22 14:01:34 3700 [Note] InnoDB: The InnoDB memory heap is disabled
2015-01-22 14:01:34 3700 [Note] InnoDB: Mutexes and rw_locks use Windows interlo
cked functions
2015-01-22 14:01:34 3700 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-01-22 14:01:34 3700 [Note] InnoDB: Not using CPU crc32 instructions
2015-01-22 14:01:34 3700 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-01-22 14:01:34 3700 [Note] InnoDB: Completed initialization of buffer pool
2015-01-22 14:01:34 3700 [Note] InnoDB: Highest supported file format is Barracu
da.
2015-01-22 14:01:35 3700 [Note] InnoDB: 128 rollback segment(s) are active.
2015-01-22 14:01:35 3700 [Note] InnoDB: Waiting for purge to start
2015-01-22 14:01:35 3700 [Note] InnoDB: 5.6.12 started; log sequence number 1626
077
2015-01-22 14:01:35 3700 [Note] Server hostname (bind-address): '*'; port: 3306
2015-01-22 14:01:35 3700 [Note] IPv6 is available.
2015-01-22 14:01:35 3700 [Note] - '::' resolves to '::';
2015-01-22 14:01:35 3700 [Note] Server socket created on IP: '::'.
2015-01-22 14:01:35 3700 [Note] mysqld: ready for connections.
Version: '5.6.12' socket: '' port: 3306 MySQL Community Server (GPL)


看到这个结果就说明MySQL已经起来了。
再开一个DOS窗口,同样切到mysql bin目录下,
E:\wamp\bin\mysql\mysql5.6.12\bin>mysql -u root mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.12 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 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> UPDATE user SET Password=PASSWORD(’123456’) where USER=’root’;
ERROR 1054 (42S22): Unknown column '’root’' in 'where clause'
mysql> update user set password=PASSWORD('123456') where user='root';
Query OK, 3 rows affected (0.03 sec)
Rows matched: 3 Changed: 3 Warnings: 0

你可能感兴趣的:(记录下解决mysql“Access denied for user 'root'@'localhost'”)