绿色版 mysql 安装配置

  • A+
所属分类:数据库技术

好多朋友对于mysql的配置不是很清楚,其实最新本的配置也是这样的,建议大家到s.jb51.net去下载一些服务器软件。

一、下载MySQL

http://www.mysql.org/downloads

我下载的是mysql-noinstall-5.0.67-win32.zip

二、安装过程

1、解压缩 mysql-noinstall-5.0.67-win32.zip 到一个C盘,重新命名为 MySQL5 。
假定MYSQL_HOME=C:\ MySQL5

2、编辑mysql的运行配置文件my.ini,如果没有,可以拿my-medium.ini复制然后更名成 my.ini

  1. # Example MySQL config file for medium systems.
  2. #
  3. # This is for a system with little memory (32M - 64M) where MySQL plays
  4. # an important part, or systems up to 128M where MySQL is used together with
  5. # other programs (such as a web server)
  6. #
  7. # You can copy this file to
  8. # /etc/my.cnf to set global options,
  9. # mysql-data-dir/my.cnf to set server-specific options (in this
  10. # installation this directory is C:\mysql\data) or
  11. # ~/.my.cnf to set user-specific options.
  12. #
  13. # In this file, you can use all long options that a program supports.
  14. # If you want to know which options a program supports, run the program
  15. # with the "--help" option.
  16. # The following options will be passed to all MySQL clients
  17. [client]
  18. #password   = your_password
  19. port        = 3306
  20. socket      = /tmp/mysql.sock
  21. # Here follows entries for some specific programs
  22. # The MySQL server
  23. [mysqld]
  24. basedir = "C:\MySQL5"
  25. datadir = "C:\MySQL5\data"
  26. default-character-set=utf8
  27. port        = 3306
  28. socket      = /tmp/mysql.sock
  29. skip-locking
  30. key_buffer = 16M
  31. max_allowed_packet = 1M
  32. table_cache = 64
  33. sort_buffer_size = 512K
  34. net_buffer_length = 8K
  35. read_buffer_size = 256K
  36. read_rnd_buffer_size = 512K
  37. myisam_sort_buffer_size = 8M
  38. # Don't listen on a TCP/IP port at all. This can be a security enhancement,
  39. if all processes that need to connect to mysqld run on the same host.
  40. # All interaction with mysqld must be made via Unix sockets or named pipes.
  41. # Note that using this option without enabling named pipes on Windows
  42. # (via the "enable-named-pipe" option) will render mysqld useless!
  43. #
  44. #skip-networking
  45. # Disable Federated by default
  46. skip-federated
  47. # Replication Master Server (default)
  48. # binary logging is required for replication
  49. log-bin=mysql-bin
  50. # required unique id between 1 and 2^32 - 1
  51. # defaults to 1 if master-host is not set
  52. # but will not function as a master if omitted
  53. server-id   = 1
  54. # Replication Slave (comment out master section to use this)
  55. #
  56. # To configure this host as a replication slave, you can choose between
  57. # two methods :
  58. #
  59. 1) Use the CHANGE MASTER TO command (fully described in our manual) -
  60. #    the syntax is:
  61. #
  62. #    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,
  63. #    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;
  64. #
  65. #    where you replace <host>, <user>, <password> by quoted strings and
  66. #    <port> by the master's port number (3306 by default).
  67. #
  68. #    Example:
  69. #
  70. #    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
  71. #    MASTER_USER='joe', MASTER_PASSWORD='secret';
  72. #
  73. # OR
  74. #
  75. 2) Set the variables below. However, in case you choose this method, then
  76. #    start replication for the first time (even unsuccessfully, for example
  77. #    if you mistyped the password in master-password and the slave fails to
  78. #    connect), the slave will create a master.info file, and any later
  79. #    change in this file to the variables' values below will be ignored and
  80. #    overridden by the content of the master.info file, unless you shutdown
  81. #    the slave server, delete master.info and restart the slaver server.
  82. #    For that reason, you may want to leave the lines below untouched
  83. #    (commented) and instead use CHANGE MASTER TO (see above)
  84. #
  85. # required unique id between 2 and 2^32 - 1
  86. # (and different from the master)
  87. # defaults to 2 if master-host is set
  88. # but will not function as a slave if omitted
  89. #server-id       = 2
  90. #
  91. # The replication master for this slave - required
  92. #master-host     =   <hostname>
  93. #
  94. # The username the slave will use for authentication when connecting
  95. # to the master - required
  96. #master-user     =   <username>
  97. #
  98. # The password the slave will authenticate with when connecting to
  99. # the master - required
  100. #master-password =   <password>
  101. #
  102. # The port the master is listening on.
  103. # optional - defaults to 3306
  104. #master-port     =  <port>
  105. #
  106. # binary logging - not required for slaves, but recommended
  107. #log-bin=mysql-bin
  108. # Point the following paths to different dedicated disks
  109. #tmpdir     = /tmp/
  110. #log-update     = /path-to-dedicated-directory/hostname
  111. # Uncomment the following if you are using BDB tables
  112. #bdb_cache_size = 4M
  113. #bdb_max_lock = 10000
  114. # Uncomment the following if you are using InnoDB tables
  115. #innodb_data_home_dir = C:\mysql\data/
  116. #innodb_data_file_path = ibdata1:10M:autoextend
  117. #innodb_log_group_home_dir = C:\mysql\data/
  118. #innodb_log_arch_dir = C:\mysql\data/
  119. # You can set .._buffer_pool_size up to 50 - 80 %
  120. # of RAM but beware of setting memory usage too high
  121. #innodb_buffer_pool_size = 16M
  122. #innodb_additional_mem_pool_size = 2M
  123. # Set .._log_file_size to 25 % of buffer pool size
  124. #innodb_log_file_size = 5M
  125. #innodb_log_buffer_size = 8M
  126. #innodb_flush_log_at_trx_commit = 1
  127. #innodb_lock_wait_timeout = 50
  128. [mysqldump]
  129. quick
  130. max_allowed_packet = 16M
  131. [mysql]
  132. no-auto-rehash
  133. # Remove the next comment character if you are not familiar with SQL
  134. #safe-updates
  135. [isamchk]
  136. key_buffer = 20M
  137. sort_buffer_size = 20M
  138. read_buffer = 2M
  139. write_buffer = 2M
  140. [myisamchk]
  141. key_buffer = 20M
  142. sort_buffer_size = 20M
  143. read_buffer = 2M
  144. write_buffer = 2M
  145. [mysqlhotcopy]
  146. interactive-timeout

[mysqld]
# 设置mysql的安装目录
basedir=$MYSQL_HOME
# 设置mysql数据库的数据的存放目录,必须是data,或者是\\xxx\data
datadir=$MYSQL_HOME\data
# 设置mysql服务器的字符集
default-character-set=utf8

[client]
# 设置mysql客户端的字符集
default-character-set=gbk

3、安装mysql服务
从MS-DOS窗口进入目录E:\myserver\mysql-5.0.37-win32\bin,运行如下命令:
mysqld --install mysql --defaults-file=C:\MySQL5\my.ini

4、启动mysql数据库
还在上面的命令窗口里面,输入命令:net start mysql
这样就启动了mysql 服务。

5、停止服务
执行 net stop mysql 即可
6、删除服务
执行mysqld --remove mysql 即可

7、修改密码
以上安装完毕之后,默认的root用户密码为空的。为了安全起见,需要设置一个root用户的密码。

  1. <STRONG><SPAN style="COLOR: #ffffff" style="COLOR: #ffffff">C:\>cd MySQL5
  2. C:\MySQL5>cd bin
  3. C:\MySQL5\bin>mysql -uroot -p
  4. Enter password:
  5. Welcome to the MySQL monitor.  Commands end with ; or \g.
  6. Your MySQL connection id is 3
  7. Server version: 5.0.67-community-log MySQL Community Edition (GPL)
  8. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  9. mysql> use mysql
  10. Database changed
  11. mysql> update User set Password=PASSWORD('admin') where User='root';
  12. Query OK, 2 rows affected (0.08 sec)
  13. Rows matched: 2  Changed: 2  Warnings: 0</SPAN>
  14. </STRONG>