现在的位置: 首页 > 综合 > 正文

MySQL Win免安装版配置

2013年12月08日 ⁄ 综合 ⁄ 共 3242字 ⁄ 字号 评论关闭

1、下载mysql-5.6.10-winx64.zip(官网没有64位msi安装文件,否则不用手动配置这么麻烦);

2、 解压至某一目录,比如D:\code\mysql-5.6.10-winx64,这是MySQL的程序目录;

3、将D:\code\mysql-5.6.10-winx64\bin添加到path环境变量;

4、新建一目录,作为MySQL数据目录,如D:\code\mysql_data,将D:\code\mysql-5.6.10-winx64\data复制到D:\code\mysql_data\data,这里面有MySQL自带的数据库和一些日志文件;

5、将D:\code\mysql-5.6.10-winx64里的my-default.ini配置文件移到D:\code\mysql_data,重命名为my.ini,当然也可以不这样组织目录结构,系统搜索my.ini选项文件的顺序可以参看http://dev.mysql.com/doc/refman/5.1/en/option-files.html

6、编写my.ini文件,比如我的:

[html] view
plain
copy

  1. [WinMySQLAdmin]   
  2. Server=D:/code/mysql-5.6.10-winx64/bin/mysqld.exe  
  3.   
  4. [client]  
  5. no-beep  
  6.   
  7. # pipe  
  8. socket=mysql  
  9. port=3306  
  10.   
  11. [mysql]  
  12.   
  13. default-character-set=utf8  
  14.   
  15. # For advice on how to change settings please see  
  16. # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html  
  17. # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the  
  18. # *** default location during install, and will be replaced if you  
  19. # *** upgrade to a newer version of MySQL.  
  20.   
  21. [mysqld]  
  22.   
  23. explicit_defaults_for_timestamp = TRUE  
  24.   
  25. # Remove leading # and set to the amount of RAM for the most important data  
  26. # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.  
  27. innodb_buffer_pool_size = 2G  
  28.   
  29. # Remove leading # to turn on a very important data integrity option: logging  
  30. # changes to the binary log between backups.  
  31. # log_bin  
  32.   
  33. # These are commonly set, remove the # and set as required.  
  34.   
  35. basedir="D:\code\mysql-5.6.10-winx64\"  
  36. datadir="D:\code\mysql_data\data\"  
  37.   
  38. port=3306  
  39. server_id=1  
  40.   
  41. general-log=0  
  42. general_log_file="mysql_general.log"  
  43. slow-query-log=1  
  44. slow_query_log_file="mysql_slow_query.log"  
  45. long_query_time=10  
  46.   
  47. log-error="mysql_error_log.err"  
  48.   
  49.   
  50. default-storage-engine=INNODB  
  51. max_connections=1024  
  52. query_cache_size=128M  
  53. key_buffer_size=128M  
  54. innodb_flush_log_at_trx_commit=1  
  55. innodb_thread_concurrency=128  
  56. innodb_autoextend_increment=128M  
  57. tmp_table_size=128M  
  58.   
  59.   
  60. # Remove leading # to set options mainly useful for reporting servers.  
  61. # The server defaults are faster for transactions and fast SELECTs.  
  62. # Adjust sizes as needed, experiment to find the optimal values.  
  63. join_buffer_size = 128M  
  64. sort_buffer_size = 2M  
  65. read_rnd_buffer_size = 2M   
  66.   
  67. #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES   
  68. sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"  
  69. character-set-server=utf8  


其中

[html] view
plain
copy

  1. [WinMySQLAdmin]   
  2. Server=D:/code/mysql-5.6.10-winx64/bin/mysqld.exe  


组是我net start mysql后控制台提示出错,找不到指定文件后添加的,

[html] view
plain
copy

  1. explicit_defaults_for_timestamp = TRUE  


属性是mysqld --install MySQL --defaults-file=D:\code\mysql_data\my.ini后提示

[html] view
plain
copy

  1. [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.  
  2. Please use --explicit_defaults_for_timestamp server option (see  
  3. documentation for more details).  


添加的,

[html] view
plain
copy

  1. basedir="D:\code\mysql-5.6.10-winx64\"  
  2. datadir="D:\code\mysql_data\data\"  


分别指向MySQL的程序目录和数据目录,注意写路径时可能出现的一些错误,如双引号、路径分隔符,其余的属性主要是优化MySQL配置的,可以通过show status查看;

7、输入mysqld --install MySQL --defaults-file=D:\code\mysql_data\my.ini命令,将mysql作为win系统服务,如果出错或想重命名服务名,可以mysqld --remove,具体可以看http://dev.mysql.com/doc/refman/5.1/en/windows-start-service.html

8、输入net start mysql启动服务;

OK,现在就可以通过mysql -h127.0.0.1 -P3306 -utest -p来跑数据库了。

抱歉!评论已关闭.