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

本文介绍如何在Windows环境下使用WAMP配置启动MySQL 5.6.12,并通过命令行重置root用户的密码。文章展示了具体的命令行操作步骤及遇到未知列名错误的解决方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值