zoukankan      html  css  js  c++  java
  • MySQL 没有 data 目录的解决方法或者重建 data 目录

    MySQL 没有 data 目录的解决方法或者重建 data 目录

    原创 2016年04月18日 04:25:52
     

    下载 MySQL 免安装(zip)版,从 5.7 版本以后,不再含有 data 目录,没有 data 目录也就是没有默认数据库,需要用户手动创建。

    运行创建 data 的命令

    D:mysql5.7.12in>mysqld --initialize-insecure --user=mysql

    将自动创建默认目录于 home 位置,之后可以通过 my.ini 设置到任意位置

    D:/mysql/5.7.12/data

    创建完成并启动服务器,此时密码为空

    /bin/mysql -u root -p 即可进入


    简单的 my.ini 设置

    文件位置默认 d:mysql5.7.12,设置服务时可以选为其他位置。
    设置 data 目录和 bin 目录,且设置字符集为 utf-8.

    1. # For advice on how to change settings please see  
    2. # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html  
    3. # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the  
    4. # *** default location during install, and will be replaced if you  
    5. # *** upgrade to a newer version of MySQL.  
    6.   
    7. [mysqld]  
    8.   
    9. # Remove leading # and set to the amount of RAM for the most important data  
    10. # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.  
    11. # innodb_buffer_pool_size = 128M  
    12.   
    13. # Remove leading # to turn on a very important data integrity option: logging  
    14. # changes to the binary log between backups.  
    15. # log_bin  
    16.   
    17. # These are commonly set, remove the # and set as required.  
    18. # basedir = .....  
    19. # datadir = .....  
    20. # port = .....  
    21. # server_id = .....  
    22.   
    23. basedir = "d:/mysql/5.7.12/"  
    24. datadir = "d:/mysql/data"  
    25. port = 3306  
    26.   
    27.   
    28. # Remove leading # to set options mainly useful for reporting servers.  
    29. # The server defaults are faster for transactions and fast SELECTs.  
    30. # Adjust sizes as needed, experiment to find the optimal values.  
    31. # join_buffer_size = 128M  
    32. # sort_buffer_size = 2M  
    33. # read_rnd_buffer_size = 2M   
    34.   
    35. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES   
    36.   
    37. character_set_server=utf8  
    38.   
    39. max_connections = 1500  
    40. max_connect_errors = 150  

    Windows 下将 mysql 作为服务启动的命令

    1. mysqld --install "MySQL 5.7" --defaults-file="d:/mysql/my.ini"  


    参考资料

    https://dev.mysql.com/doc/refman/5.7/en/mysql-install-db.html

    https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html

    MySQL 下载

    http://dev.mysql.com/downloads/

  • 相关阅读:
    python遍历字典元素
    Asp.net网站优化【转】
    三、HTTP协议
    二、 OSI模型的实现TCP 、IP
    一、OSI模型
    JVM原理:4 运行期优化
    JS:jquery插件表格单元格合并.
    28-语言入门-28-1的个数
    27-语言入门-27-成绩转换
    26-语言入门-26-兄弟郊游问题
  • 原文地址:https://www.cnblogs.com/yasepix/p/7861378.html
Copyright © 2011-2022 走看看