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

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

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

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

运行创建 data 的命令

D:\mysql\5.7.12\bin>mysqld --initialize-insecure --user=mysql

 

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

D:/mysql/5.7.12/data

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

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


简单的 my.ini 设置

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

[plain] view plain copy
  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 作为服务启动的命令

[plain] view plain copy
  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/

转载于:https://www.cnblogs.com/yasepix/p/7861378.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值