安装mysql

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. [client]
  4. no-beep
  5. #pipe
  6. #socket=mysql
  7. port=3306
  8. [mysql]
  9. default-character-set=utf8
  10. #Foradviceonhowtochangesettingspleasesee
  11. #http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
  12. #***DONOTEDITTHISFILE.It'satemplatewhichwillbecopiedtothe
  13. #***defaultlocationduringinstall,andwillbereplacedifyou
  14. #***upgradetoanewerversionofMySQL.
  15. [mysqld]
  16. explicit_defaults_for_timestamp=TRUE
  17. #Removeleading#andsettotheamountofRAMforthemostimportantdata
  18. #cacheinMySQL.Startat70%oftotalRAMfordedicatedserver,else10%.
  19. innodb_buffer_pool_size=2G
  20. #Removeleading#toturnonaveryimportantdataintegrityoption:logging
  21. #changestothebinarylogbetweenbackups.
  22. #log_bin
  23. #Thesearecommonlyset,removethe#andsetasrequired.
  24. basedir="D:\code\mysql-5.6.10-winx64\"
  25. datadir="D:\code\mysql_data\data\"
  26. port=3306
  27. server_id=1
  28. general-log=0
  29. general_log_file="mysql_general.log"
  30. slow-query-log=1
  31. slow_query_log_file="mysql_slow_query.log"
  32. long_query_time=10
  33. log-error="mysql_error_log.err"
  34. default-storage-engine=INNODB
  35. max_connections=1024
  36. query_cache_size=128M
  37. key_buffer_size=128M
  38. innodb_flush_log_at_trx_commit=1
  39. innodb_thread_concurrency=128
  40. innodb_autoextend_increment=128M
  41. tmp_table_size=128M
  42. #Removeleading#tosetoptionsmainlyusefulforreportingservers.
  43. #TheserverdefaultsarefasterfortransactionsandfastSELECTs.
  44. #Adjustsizesasneeded,experimenttofindtheoptimalvalues.
  45. #join_buffer_size=128M
  46. #sort_buffer_size=2M
  47. #read_rnd_buffer_size=2M
  48. #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  49. sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
  50. 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]TIMESTAMPwithimplicitDEFAULTvalueisdeprecated.
  2. Pleaseuse--explicit_defaults_for_timestampserveroption(see
  3. documentationformoredetails).

添加的,

[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来跑数据库了。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值