Windows从noinstall zip安装MySQL免安装版

对于Windows的MySQL的安装其实很简单。个人推荐使用免安装版的MySQL,这种版本只要下来,解压缩后配置一下就可以使用了。而对那种安装包则就比较麻烦,本篇也不做介绍。因为周围有许多人的MySQL安装使用安装程序,而安装到一半,配置不会弄,MySQL数据库也弄的怪怪的。

第一步,下载MySQL的免安装版压缩包

好了,对于MySQL的免安装程序,我们先要下载一个MySQL的压缩包。下载地址:MySQL官网下载或者腾讯旋风分享下载

说明:在MySQL下载的时候,会有个让你login或sign up的按钮,不用注册了,看下方有个 No thanks, just start my download.的链接。点击可直接下载,不用登录。

对于解压缩出来的MySQL,有几个配置文件样例,有my-small.ini、my-huge.ini等等,我们只要复制其中的一个,并命名为my.ini

small、medium、large、huge、heavy的配置区别
1
2
3
4
Small: System has Medium: System has at least 64MB memory
Large: System has at least 512MB memory and the server will run mainly MySQL.
Huge: System has at least 1GB memory and the server will run mainly MySQL.
Heavy: System has at least 4GB memory and the server will run mainly MySQL.

第二步,配置MySQL

将第一步复制的配置文件my.ini打开,我们需要修改一下basedir(MySQL数据库的文件夹)和datadir(MySQL数据库的数据目录)。如下,

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Example MySQL config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is C:\mysql\data) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
 
# The following options will be passed to all MySQL clients
[client]
#password   = your_password
port        = 3306
socket      = /tmp/mysql.sock
 
# Here follows entries for some specific programs
 
# The MySQL server
[mysqld]
port        = 3306
socket      = /tmp/mysql.sock
#skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
# set basedir to your installation path
basedir =E:/Program Files (x86)1/mysql-5.5.27-winx64
# set datadir to the location of your data directory
datadir =E:/Program Files (x86)1/mysql-5.5.27-winx64/data
 
# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
 
# Disable Federated by default
skip-federated
 
# Replication Master Server (default)
# binary logging is required for replication
log-bin =mysql-bin
 
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id   = 1
 
# Replication Slave (comment out master section to use this)
#
# To configure this host as a replication slave, you can choose between
# two methods :
#
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -
#    the syntax is:
#
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
#
#    where you replace <host>, <user>, <password> by quoted strings and
#    <port> by the master's port number (3306 by default).
#
#    Example:
#
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
#    MASTER_USER='joe', MASTER_PASSWORD='secret';
#
# OR
#
# 2) Set the variables below. However, in case you choose this method, then
#    start replication for the first time (even unsuccessfully, for example
#    if you mistyped the password in master-password and the slave fails to
#    connect), the slave will create a master.info file, and any later
#    change in this file to the variables' values below will be ignored and
#    overridden by the content of the master.info file, unless you shutdown
#    the slave server, delete master.info and restart the slaver server.
#    For that reason, you may want to leave the lines below untouched
#    (commented) and instead use CHANGE MASTER TO (see above)
#
# required unique id between 2 and 2^32 - 1
# (and different from the master)
# defaults to 2 if master-host is set
# but will not function as a slave if omitted
#server-id       = 2
#
# The replication master for this slave - required
#master-host     =   <hostname>
#
# The username the slave will use for authentication when connecting
# to the master - required
#master-user     =   <username>
#
# The password the slave will authenticate with when connecting to
# the master - required
#master-password =   <password>
#
# The port the master is listening on.
# optional - defaults to 3306
#master-port     =  <port>
#
# binary logging - not required for slaves, but recommended
#log-bin=mysql-bin
 
# Point the following paths to different dedicated disks
#tmpdir     = /tmp/
#log-update     = /path-to-dedicated-directory/hostname
 
# Uncomment the following if you are using BDB tables
#bdb_cache_size = 4M
#bdb_max_lock = 10000
 
# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = C:\mysql\data/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = C:\mysql\data/
#innodb_log_arch_dir = C:\mysql\data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50
 
[mysqldump]
quick
max_allowed_packet = 16M
 
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
 
[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
 
[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
 
[mysqlhotcopy]
interactive-timeout

将这两处的地址换成自己的MySQL的地址,已经date目录。注意斜线的方向,使用E:/Program Files/mysql-5.5.27-winx64或者E:\\Program Files\\mysql-5.5.27-winx64。仅有这两处需要改动,其他不必改动了,除非特殊需要。

第三步,启动MySQL

要启动MySQL也很简单,打开命令提示符。输入一下两个命令

1
2
cd /d E:\Program Files\mysql-5.5.27-winx64\bin\
mysqld --console

会出现一下内容就成功了。

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
130317 20:11:05 [Note] Plugin 'FEDERATED' is disabled.
130317 20:11:05 InnoDB: The InnoDB memory heap is disabled
130317 20:11:05 InnoDB: Mutexes and rw_locks use Windows interlocked functions
130317 20:11:05 InnoDB: Compressed tables use zlib 1.2.3
130317 20:11:05 InnoDB: Initializing buffer pool, size = 128.0M
130317 20:11:05 InnoDB: Completed initialization of buffer pool
130317 20:11:05 InnoDB: highest supported file format is Barracuda.
130317 20:11:06  InnoDB: Waiting for the background threads to start
130317 20:11:07 InnoDB: 1.1.8 started; log sequence number 14128205
130317 20:11:07 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
130317 20:11:07 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
130317 20:11:07 [Note] Server socket created on IP: '0.0.0.0'.
130317 20:11:07 [Note] Event Scheduler: Loaded 0 events
130317 20:11:07 [Note] mysqld: ready for connections.
Version: '5.5.27-log'  socket: ''  port: 3306  MySQL Community Server (GPL)

为了以后的方便,将里面的内容保存到startmysql.bat文件里,以后只要双击bat就可以运行mysql了。

第四步:更改MySQL密码

默认MySQL的root密码为空的,在某些地方,密码不能输入为空,所以需要更改密码。

首先先启动MySQL数据库,可以使用上面的bat启动MySQL。

然后根据下面的命令进行更改

1
2
3
4
mysql -u root -p #从命令行中进入mysql的客户端
use mysql;  #使用mysql这个数据库
update user set password=password( "root" ) where user= "root" ; #对root密码进行更改
FLUSH PRIVILEGES; #刷新一下权限

安装到Windows service服务开机自动启动

如果需要将MySQL开机自动运行,并且以服务的形式存在,那么按照本方法进行即可。以服务的形式打开MySQL,就不用再适用上面的批处理文件了。

先停止MySQL Server的运行。以管理员方式运行命令提示符

向WINDOWS添加服务

1
2
E:\Program Files\mysql-5.5.27-winx64\bin>mysqld --install MySQL5.5
Service successfully installed.

使用mysqld 并使用参数--install MySQL5.5,说明向服务注册一个叫MySQL5.5的服务名,如果不加服务名,则使用默认的MySQL作为服务名。

注意:使用 --install 参数添加的服务为开机自动启动的。如果想要使用手工启动,那么使用参数 --install-manual代替。命令 mysqld --install-manual添加服务,需要手工启动服务。

启动MYSQL服务

第二步只是向Windows服务添加了一个MySQL5.5的服务,但是并没有启动。可以到Windows服务里启动,或者使用命令行(需要管理员权限)

1
2
3
C:\> net start MySQL5.5
MySQL5.5 服务正在启动 .
MySQL5.5 服务已经启动成功。

从服务中停止MYSQL服务

1
2
3
C:\> net stop MySQL5.5
MySQL5.5 服务正在停止.
MySQL5.5 服务已成功停止。

删除WINDOWS的MYSQL服务

1
2
E:\Program Files\mysql-5.5.27-winx64\bin>mysqld --remove MySQL5.5
Service successfully removed.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值