【MySQL】MySQL数据库再安装

解决问题

  1. 安装时提示此产品配置信息损坏,怎么办?
  2. 环境检测时未响应,怎么办?
  3. 服务不能启动,怎么办?
  4. 输入密码不能登陆,不使用密码却能登录,是什么原因?

涉及到的错误代码:windows启动MySQL服务1067、MySQL ERROR 1045

解决方法

电脑安装过MySQL,想再次安装的时候总会出些问题。一般我们会想到的就是删除安装目录中的数据、删除C盘Application Data等目录下的数据,以及删除注册表中关于MySQL的数据。一番删除之后,你会发现再次安装的时候,会提示你:

所以说删注册表还是要慎重呀。

解决步骤:

  1. 找到【控制面板】 -> 【管理工具】-> 【事件查看器】->【windows日志】

  2. 再次点击安装程序,等弹出配置信息损坏时,刷新【windows日志】中的应用程序,找到错误信息,在【常规】选项中会提示错误的原因:注册表中缺少值。
  3. 打开注册表:【Win】+【R】打开运行窗口,输入:regedit ,打开注册表。
  4. 按照之前提示的路径,删除对应的注册表。一定要选择准确。
  5. 现在就可以继续安装了。

如果这个时候,你能一步一步安装成功,那当然最好。但是现实可能并没有那么好。下面看一下我们接着会遇见的问题。

每当安装快成功的时候,检测环境时:到启动服务,就一直出现未响应...

我们手动去启动,也会提示:无法启动 错误1067。

解决步骤:

  1. 修改安装目录下的my.ini文件,将default-storage-engine=INNODB改为:
    default-storage-engine=MyISAM

  2. 启动MySQL服务。当服务启动成功后,发现安装程序,第三步检测通过,当然这并不重要,等安装完了直接【Skip】就可以了。也许它未响应的时候,直接关掉也不影响。

    也许这个时候,你的MySQL就可以使用了。但是更可能报:ERROR 1045.

  3. 在cmd窗口中输入mysql -uroot -p ,不能进入数据库。但是使用mysql、mysql -uroot却可以进入。
    这里也可以在my.ini文件中[mysqld]后面增加:
    #登录时跳过权限检查
    skip_grant_tables

      使用:mysql -uroot -p 命令进行登录,使用任意密码都可以登录。
      更改完root用户的密码后,应注释掉增加的内容。
      当改完密码后使用:mysql -uroot 进行登录时,同样会提示:
    C:UsersAdministrator>mysql -uroot
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
     这个时候就用密码登陆就好了。说明我们的更改生效了。
  4. 使用mysql -uroot进入数据库(注意:不要加“-p”),不要使用mysql命令直接进入。 因为他们所能看到的表不同。
    C:UsersAdministrator>mysql
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 30
    Server version: 5.5.62 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2018, 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> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | test               |
    +--------------------+
    2 rows in set (0.00 sec)
    
    C:UsersAdministrator>mysql -uroot
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 31
    Server version: 5.5.62 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2018, 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> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | test               |
    +--------------------+
    4 rows in set (0.00 sec)
    只有mysql -uroot才能看到user表
  5. 修改root用户的密码:
    mysql> use mysql
    Database changed
    mysql> UPDATE user SET password=PASSWORD('mysqladmin') WHERE user='root';
    Query OK, 3 rows affected (0.00 sec)
    Rows matched: 3  Changed: 3  Warnings: 0
    # 刷新MySQL权限相关的表(应该可以省略)
    mysql> flush privileges;
    Query OK, 0 rows affected (0.03 sec)
    
    mysql> select user,password From user;
    +------+-------------------------------------------+
    | user | password                                  |
    +------+-------------------------------------------+
    | root | *A5C34F28328751B780896836C8A565C5C130175E |
    | root | *A5C34F28328751B780896836C8A565C5C130175E |
    | root | *A5C34F28328751B780896836C8A565C5C130175E |
    |      |                                           |
    +------+-------------------------------------------+
    4 rows in set (0.00 sec)
    mysql> exit
    Bye
  6. 重启服务:重启服务,使用新密码登录。

终于安装成功!!!

原文地址:https://www.cnblogs.com/yan-lei/p/10257149.html