zoukankan      html  css  js  c++  java
  • 安装Windows 64 位 mysql 最新版本解压包中没有data目录和my-default.ini及服务无法启动的快速解决办法

    mysql官网下载地址:https://dev.mysql.com/downloads/mysql/

    首先安装包解压后,没有网上教程里面提到的data文件夹和my-default.ini

    配置环境变量很简单:

    新增系统环境变量:
    
    键名:MYSQL_HOME
    
    值为:E:mysql-5.7.21-winx64
    
    在path中添加%MYSQL_HOME%in

    主要注意以下几点:

    1. my-default.ini文件存不存在不重要,关键需要自己在根目录下新建一个文本文件,改名为my.ini,具体内容如下:
      [mysql]
      
      # 设置mysql客户端默认字符集
      
      default-character-set=utf8 
      
      [mysqld]
      
      #设置3306端口
      
      port = 3306 
      
      # 设置mysql的安装目录
      
      basedir=E:\mysql-5.7.21-winx64
      
      # 允许最大连接数
      
      max_connections=200
      
      # 服务端使用的字符集默认为8比特编码的latin1字符集
      
      character-set-server=utf8
      
      # 创建新表时将使用的默认存储引擎
      
      default-storage-engine=INNODB

      可以直接复制粘贴,主要修改下basedir后的路径,注意路径中为\而非

    2. 如果出现

      MySQL 服务正在启动。
      MySQL 服务无法启动。

      为了避免这个错误,需要使用命令生成data文件夹,按如下步骤安装:

    3. 1) 进入dos的命令行,一定要用administrator进入。2)进入MySQL的bin目录,输入mysqld –install可以安装MySQL。3)

      D:>cd D:Servicemysql57in
      D:Servicemysql57in>mysqld -install
      Service successfully installed.

      4)输入以下命令,可以初始化MySQL数据库,初始化了之后,会打印出MySQL的默认生成的密码,下面标红了的就是默认生成的密码。

      D:Servicemysql57in>mysqld --initialize --user=root --console
      2017-12-20T08:13:45.264865Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
      2017-12-20T08:13:45.854579Z 0 [Warning] InnoDB: New log files created, LSN=45790
      2017-12-20T08:13:45.998772Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
      2017-12-20T08:13:46.098118Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 9755c3ea-a6f1-11e5-81a3-74d02b122fb3.
      2017-12-20T08:13:46.121617Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
      2017-12-20T08:13:46.135153Z 1 [Note] A temporary password is generated for root@localhost: g!gRw!d%M0Sj

      初始化了以后,可以看到MySQL目录下,多了data目录5)D:Servicemysql57in>net start mysql

      MySQL 服务正在启动。
      MySQL 服务已经启动成功。

      6)使用默认生成的密码,进入mysql。7)

      D:Servicemysql57in>mysql -u root -p
      Enter password: ************
      Welcome to the MySQL monitor.  Commands end with ; or g.
      Your MySQL connection id is 4
      Server version: 5.7.10
      
      Copyright (c) 2000, 2017, 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>

      7)进入了mysql就可以修改默认密码了(我把默认密码修改成了root)

      mysql> set password = password('root') ;

      这个时候,Windows下的MySQL环境就已经安装好了。

  • 相关阅读:
    java操作生成jar包 和写入jar包
    jboss配置jndi连接池
    windows 域的LDAP查询相关举例
    LDAP error Code 及解决方法
    HDU 6417
    CF1299D Around the World
    codechef Chef and The Colored Grid
    Educational Codeforces Round 82 (Rated for Div. 2)
    CF1237F Balanced Domino Placements
    CF1254E Send Tree to Charlie
  • 原文地址:https://www.cnblogs.com/bkywanly/p/9538463.html
Copyright © 2011-2022 走看看