zoukankan      html  css  js  c++  java
  • mysql 系列错误解决

    参考文章来源

    https://segmentfault.com/a/1190000015678751

    https://blog.csdn.net/Tong_zhi/article/details/84716210

    https://blog.csdn.net/qq_32786873/article/details/79225039

    https://blog.csdn.net/chen97_08/article/details/81484286

    在连接数据库时,有Mysql报错:MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    于是在cmd下登录mysql也出现了同样的错误,所以得出结论:不是代码的问题,可能是配置环境的问题
    搜寻阵子后找到了解决方法
    (配置为window10,MySQL Server 8.0)

    解决方法:

    一.编辑my.ini文件

    5.7以后的版本my.ini配置文件的目录发生了改变
    放在了C:ProgramDataMySQLMySQL Server 8.0之中
    用Notepad打开后,在[mysqld]下加入skip-grant-tables,保存退出

    二.重启MySQL

    进入cmd命令行,先后输入

    net stop mysql
    net start mysql

    (如果拒绝访问的话请以管理员身份运行cmd,文末参考资料有教程)

    三.登录

    这时cmd中输入mysql -u root -p就不需要密码登录了,出现password直接回车进入
    但操作会受到限制,因为没有权限

    四.重设密码

    1.进入mysql数据库:

    mysql>use mysql;

    2.为root用户设置新密码

    mysql> update user set password=password("这里写新密码") where user="root"

      1. 接着输入:select host, user, authentication_string, plugin from user;
      注意:该命令可以查看root用户对应及其他用户的信息,此时root用户对应的authentication_string是为空的,如果不为空则使用命令 update user set authentication_string='' where user='root';需要注意的是在8.0 版本之后MySQL的password函数设置密码已经被取消,所以,update mysql.user set password='newpassword'  where user='root'; 和 update mysql.user set password=PASSWORD('newpassword') where User='root';这两条命令已经不起作用了。

      2.输入命令: alter user 'root'@'localhost' identified by 'newpassword'; 设置密码

     

    3.刷新数据库

    mysql>flush privileges;

    4.退出mysql

    mysql> quit

    五.重新编辑my.ini

    把刚才加入的“skip-grant-tables”去掉,再重启mysql

    启动MySQL报错:ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

    Mysql服务需要手动安装Mysql服务,安装命令为mysqld -install,由于本机中已经安装了mysql服务,所以有如下提示The service already exists!

  • 相关阅读:
    [引]ASP.NET MVC 4 Content Map
    [转]ASP.NET MVC 2: Model Validation
    [转]ASP.NET MVC中你必须知道的13个扩展点
    [转]Best way to sort a DropDownList in MVC3 / Razor using helper method
    [转]Sql Server参数化查询之where in和like实现详解
    [转]Oracle Stored Procedures Hello World Examples
    [转]oracle的ANYDATA数据类型
    重构中对设计模式的反思
    poj2186 Popular Cows --- 强连通
    mac下通过xcodebuild使用oclint
  • 原文地址:https://www.cnblogs.com/jianglijian/p/11672338.html
Copyright © 2011-2022 走看看