前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'

作者头像
逝兮诚
发布2019-10-30 11:59:22
3.3K0
发布2019-10-30 11:59:22
举报
文章被收录于专栏:代码人生代码人生

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/luo4105/article/details/47073601

前两天装了mysql免安装版,但是没有设账户和密码,今天新建数据库时总不成功,上网查了一下,是因为没有设密码的原因。于是去设密码,设密码要使用 “mysql” 这个数据库,但是会报错。ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'

后来发现解决办法,把my.ini中加入skip-grant-tables。

代码语言:javascript
复制
[mysqld]
skip-grant-tables

# Remove leading # and set to the amount of RAM for the most important data

就像这样,然后在去重启mysql,我是在服务中重启的。

接着打开mysql

代码语言:javascript
复制
<pre name="code" class="html"><pre name="code" class="html">Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.25 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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.
代码语言:javascript
复制

这时,便可以 use mysql了。

代码语言:javascript
复制
mysql> use mysql
Database changed
mysql>

然后修改密码

代码语言:javascript
复制
mysql> update user set password=password('12345') where user='root';
Query OK, 3 rows affected (0.05 sec)
Rows matched: 3  Changed: 3  Warnings: 0

退出,将my.ini改过来,就可以了

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015-07-26 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档