以前从没玩过mysql,这两天忽然心血来潮,感觉好玩,看了一点点文档,决定玩玩mysql,O(∩_∩)O哈哈~
今天在火车上,闲得无聊,找了一个windows版本的mysql,尝试免安装版的手动配置mysql。
大致思路:
1,手工编辑my.ini(linux上是my.cnf) 2,注册到windows服务 3,修改系统环境变量 4,测试
mysql5.1版本,如果用免安装版本的话,解压后,缺省会有一些配置文件模板,
昨天下载了一个5.6的免安装版本,发现里面只有一个my-default.ini,内容类似:
下面的内容是我稍微修改的:
# 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. [client] port=3306 [WindowsMysql5.6] Server="d:/mysql5.6/bin/mysqld.ext" [mysqld] # 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 = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. log_bin="d:/mysql5.6/binlog/" # These are commonly set, remove the # and set as required. basedir = "d:/mysql5.6/" datadir = "d:/mysql5.6/data/" port = 3306 server_id = 1 # 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
这里面看到windows下面的目录文件号居然也要用“/”,确实奇葩。
开始我用的“\”,注册服务后,启动mysql时就报错了:
D:\mysql5.6\bin>net start mysql MySQL 服务正在启动 ... MySQL 服务无法启动。 系统出错。 发生系统错误 1067。 进程意外终止。
修改成“/”后,问题解决了:
D:\mysql5.6\bin>net start mysql MySQL 服务正在启动 . MySQL 服务已经启动成功。
如果使用exe的方式安装mysql,会自动配置好环境变量。
如果用免安装的方式,那么需要手工配置环境变量:
D:\ORACLE\product\12.1.0\dbhome_1\bin;C:\Program Files (x86)\Common Files\NetSarang;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Lenovo\Fingerprint Manager Pro\;d:\mysql5.6\bin
测试一下,ok了,O(∩_∩)O哈哈~:
C:\Users\Lunar>mysql -h localhost -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.21-log MySQL Community Server (GPL) Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select version(), current_date(); +------------+----------------+ | version() | current_date() | +------------+----------------+ | 5.6.21-log | 2014-11-02 | +------------+----------------+ 1 row in set (0.04 sec) mysql>