Windows下noinstall方式安装MySQL

Windows noinstall安装MySQL

官网下载的MySQL有两种格式,一种是安装程序Installer,另外一种是zip格式的压缩包。本文就介绍zip Archive方式安装MySQL。系统环境:Windows 7 64位、mysql-5.6.22-winx64.zip。

!!!注意!5.7版本MySQL使用noinstall方式安装的话,需要在启动前初始化data目录:mysqld --initialize,如果控制台没有出现初始的随机密码,可以在data目录里面找.err的文件查看。详见

1. 解压

mysql-5.6.22-winx64.zip解压到C:\Program Files\mysql-5.6.22-winx64

2. 创建my.ini

复制默认的my-default.ini另存为my.ini,编辑my.ini

[mysqld]

basedir = C:/Program Files/mysql-5.6.22-winx64
datadir = C:/Program Files/mysql-5.6.22-winx64/data
port = 3306 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

3. 添加系统变量

新建系统变量MYSQL_HOME,并将MYSQL_HOME\bin添加到Path

MYSQL_HOME : C:/Program Files/mysql-5.6.22-winx64
Path : %Path%;%MYSQL_HOME%\bin;

4. 命令行启动MySQL

在命令行执行mysqld启动MySQL,也可以使用mysqld --console来输出一些信息:

C:\Users\Seay>mysqld --console
2015-01-15 23:05:17 0 [Warning] TIMESTAMP with implicit DEFAULT value is depreca
ted. Please use --explicit_defaults_for_timestamp server option (see documentati
on for more details).
2015-01-15 23:05:17 1072 [Note] Plugin 'FEDERATED' is disabled.
2015-01-15 23:05:17 1072 [Note] InnoDB: Using atomics to ref count buffer pool p
ages
2015-01-15 23:05:17 1072 [Note] InnoDB: The InnoDB memory heap is disabled
2015-01-15 23:05:17 1072 [Note] InnoDB: Mutexes and rw_locks use Windows interlo
cked functions
2015-01-15 23:05:17 1072 [Note] InnoDB: Memory barrier is not used
2015-01-15 23:05:17 1072 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-01-15 23:05:17 1072 [Note] InnoDB: Not using CPU crc32 instructions
2015-01-15 23:05:17 1072 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-01-15 23:05:17 1072 [Note] InnoDB: Completed initialization of buffer pool
2015-01-15 23:05:18 1072 [Note] InnoDB: Highest supported file format is Barracu
da.
2015-01-15 23:05:18 1072 [Note] InnoDB: 128 rollback segment(s) are active.
2015-01-15 23:05:18 1072 [Note] InnoDB: Waiting for purge to start
2015-01-15 23:05:18 1072 [Note] InnoDB: 5.6.22 started; log sequence number 1625
977
2015-01-15 23:05:18 1072 [Warning] No existing UUID has been found, so we assume
 that this is the first time that this server has been started. Generating a new
 UUID: eaf491cf-9cc7-11e4-8689-705ab663d076.
2015-01-15 23:05:18 1072 [Note] Server hostname (bind-address): '*'; port: 3306
2015-01-15 23:05:18 1072 [Note] IPv6 is available.
2015-01-15 23:05:18 1072 [Note]   - '::' resolves to '::';
2015-01-15 23:05:18 1072 [Note] Server socket created on IP: '::'.
2015-01-15 23:05:19 1072 [Note] Event Scheduler: Loaded 0 events
2015-01-15 23:05:19 1072 [Note] mysqld: ready for connections.
Version: '5.6.22'  socket: ''  port: 3306  MySQL Community Server (GPL)

这时便启动了MySQL。如果想关闭MySQL,可以再启动一个命令行执行mysqladmin -u root shutdown。当然如果有密码需要添加-p

5. 将MySQL安装到Windows服务

可以在命令行运行mysqld --install将MySQL安装成服务,注意这个方式安装的服务是开机自动启动的。也可以执行mysqld --install-manual将MySQL安装成手动启动的服务。

这种方式下,在命令行执行NET START MySQL启动MySQL服务,执行NET STOP MySQL关闭MySQL服务。

如果想删除MySQL服务,可以在关闭MySQL服务之后,在控制台执行mysqld --remove

6. 测试MySQL安装状态

可以使用下面的命令测试MySQL是否安装并启动成功:

mysqlshow
mysqlshow -u root mysql
mysqladmin version status proc
mysql test

参考资料

  1. Installing MySQL on Microsoft Windows Using a noinstall Zip Archive
  2. Windows从noinstall zip安装MySQL免安装版
posted @ 2015-01-17 16:22  sincerelywy  阅读(441)  评论(0编辑  收藏  举报