错误详情

使用pymysql连接数据库mysql,一直无法连接上,

conn = pymysql.connect(host='localhost', port=3306, user='root', passwd='1234', db='test', charset='utf8')

原因是自己的mysql没有密码,即root进入直接enter就可以进入数据库,但这样的数据库在使用其他连接可能都会出现这种问题,所以解决问题的第一步就是给root设置一个密码。

步骤如下:

[root ~]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:NO)

1.停止mysql服务

[root ~]# net stop mysql

2.在没有任何特权的情况下启动mysql:

首先找到mysql安装路径,找到my.ini文件,在该文件末尾加上skip-grant-tables

然后启动mysql服务

[root ~]# net start mysql

3.输入mysql命令符

[root ~]# mysql -u root
mysql>

4.修复root用户的权限设置

mysql> use mysql;
Database changed
mysql> select * from user;
Empty set (0.00 sec)
mysql> truncate table user;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on *.* to root@localhost identified by 'YourNewPassword' with grant option;
Query OK, 0 rows affected (0.01 sec)

确认结果:

    mysql> select host, user from user;
+-----------+------+
| host | user |
+-----------+------+
| localhost | root |
+-----------+------+
1 row in set (0.00 sec)

5.退出外壳程序并以正常模式重启mysql

mysql> quit;
[root ~]# kill -KILL [PID of mysqld_safe]
[root ~]# kill -KILL [PID of mysqld]
[root ~]# service mysql start

6.现在,可以使用设置的密码以root用户身份成功登录

 [root ~]# mysql -u root -pYourNewPassword
mysql>

  

Access denied for user 'root@localhost' (using password:NO)问题的解决的更多相关文章

  1. MySQL5.5出面ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)问题的解决办法

    问题描述 安装完MySQL5.5数据库,使用Navicat Premium以及命令窗口连接数据库都报以下错误: ERROR 1045 (28000): Access denied for user ' ...

  2. mariadb mysql 报'Access denied for user 'root'@'localhost' (using password: NO)'错误的解决

    C:\Program Files\MariaDB 10.2\bin>mysql admin -u root password "x123456789" mysql Ver 1 ...

  3. MySQL 出现 Access denied for user 'root'@'localhost' (using password: YES) 错误

    登录某台服务器的mysql时候总报错: mysql2/client.rb:58:in `connect': Access denied for user 'root'@'localhost' (usi ...

  4. ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)(转)

    前两天也偶尔出现这个错误,也没在意,因为我重新修改一下mysql的root密码后又可以用了,但昨天却不行,我把root密码修改以后虽然当时能用, 一旦重新进入就都不能用了,可我的密码明明没有错啊?今天 ...

  5. linux连接mysql 出现Access denied for user 'root'@'localhost'(using password: YES)错误解决方案

    linux连接mysql /usr/local/mysql/bin/mysql -uroot -p 输入密码出现Access denied for user 'root'@'localhost'(us ...

  6. 重置密码解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

    出现报错: Warning: World-writable config file '/etc/my.cnf' is ignored // 该文件权限过高ERROR 1045 (28000): Acc ...

  7. java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) 解决办法

    一.背景 在Spark中,将DStream写入到MySQL出现错误:java.sql.SQLException: Access denied for user 'root'@'localhost' ( ...

  8. 解决mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO/YES)

    一.问题 有时候我们登录Mysql输入密码的时候,会出现这种情况 mysql -u root -p Enter Password > '密码' 错误:ERROR 1045 (28000): Ac ...

  9. MySql Access denied for user 'root'@'localhost' (using password:YES) 解决方案

    关于昨天下午说的MySQL服务无法启动的问题,解决之后没有进入数据库,就直接关闭了电脑. 今早打开电脑,开始-运行 输入"mysql -uroot -pmyadmin"后出现以下错 ...

随机推荐

  1. git到GitHub的操作和遇到的一些问题

    一.新建完项目后执行git git status //查看状态,任何时候都可以用 1. git init //初始化文件夹,并创建.git本地仓库(.git默认隐藏) 2. git add . //把 ...

  2. docker容器和虚拟机的比较

    containers:容器是在应用层的抽象化,多个容器能够运行在同一台机器上,和其他容器共享操作系统的核,每个容器运行都独立的运行在用户的空间内.容器需要的空间比虚拟机要小(容器镜像的大小一般为MBs ...

  3. ASP.NET Core on K8S深入学习(8)数据管理

    本篇已加入<.NET Core on K8S学习实践系列文章索引>,可以点击查看更多容器化技术相关系列文章. 在Docker中我们知道,要想实现数据的持久化(所谓Docker的数据持久化即 ...

  4. 【解决】Failed to restart network.service: Unit network.service not found.

    问题:使用systemctl restart network 或 service network restart 命令重启网卡失败. 分析:原因其实也很简单,命令用错了,造成了找不到相应的网卡服务. ...

  5. SpringCloud服务配置中心

    SpringCloud Config简介 Spring Cloud Config 是 Spring Cloud 团队创建的一个全新项目,用来为分布式系统中的基础设施和微服务应用提供集中化的外部配置支持 ...

  6. 《C#并发编程经典实例》学习笔记—2.9 处理 async void 方法的异常

    问题 需要处理从 async void 方法传递出来的异常. 解决方案 书中建议尽量不写 async void 这样的方法,如果非写不可,建议在方法内部 try catch 所有的代码,即在方法内部处 ...

  7. Dynamics 365中开发和注册插件介绍

    我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...

  8. 012.MongoDB读写分离

    一 读写分离概述 1.1 读写分离描述 从应用程序角度来看,使用Replica Set 和使用单台mongo很像.默认的驱动程序会连接primary节点,并且将所有读写请求都路由到主节点.但也可以通过 ...

  9. 微服务与K8S容器云平台架构

    微服务与K8S容器云平台架构 微服务与12要素 网络 日志收集 服务网关 服务注册 服务治理- java agent 监控 今天先到这儿,希望对技术领导力, 企业管理,系统架构设计与评估,团队管理, ...

  10. 项目如何部署在linux系统上

    前面已经安装好centos的系统,网络配置,以及部署的环境已成功啦... 下面记录的是如何部署一个项目 四个步骤: (1)放war包 (2)执行数据库脚本 (3)修改数据库的配置文件 (4)重启tom ...