MySQL Win免安装版配置

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文件,比如我的:

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

[client]
no-beep

# pipe
# socket=mysql
port=3306

[mysql]

default-character-set=utf8

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

explicit_defaults_for_timestamp = TRUE

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 2G

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.

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

port=3306
server_id=1

general-log=0
general_log_file="mysql_general.log"
slow-query-log=1
slow_query_log_file="mysql_slow_query.log"
long_query_time=10

log-error="mysql_error_log.err"


default-storage-engine=INNODB
max_connections=1024
query_cache_size=128M
key_buffer_size=128M
innodb_flush_log_at_trx_commit=1
innodb_thread_concurrency=128
innodb_autoextend_increment=128M
tmp_table_size=128M


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
character-set-server=utf8

其中

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

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

explicit_defaults_for_timestamp = TRUE

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

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

添加的,

basedir="D:\code\mysql-5.6.10-winx64\"
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来跑数据库了。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值