添加mysql服務:
第一步,在mysql根目錄下添加檔案“my.ini",檔案內容為:
# Example MySQL config file for large systems.<br />#<br /># This is for a large system with memory = 512M where the system runs mainly<br /># MySQL.<br />#<br /># You can copy this file to<br /># /etc/my.cnf to set global options,<br /># mysql-data-dir/my.cnf to set server-specific options (in this<br /># installation this directory is /usr/local/var) or<br /># ~/.my.cnf to set user-specific options.<br />#<br /># In this file, you can use all long options that a program supports.<br /># If you want to know which options a program supports, run the program<br /># with the "--help" option.<br /># The following options will be passed to all MySQL clients<br />[client]<br />#password= your_password<br />port= 3306<br />socket= /tmp/mysql.sock<br /># Here follows entries for some specific programs<br /># The MySQL server<br />[mysqld]<br />basedir="C:/Program Files/cosl_ZWL_App/mysql-5.1.6-alpha-win32/"<br />datadir="C:/Program Files/cosl_ZWL_App/mysql-5.1.6-alpha-win32/data/"<br />port= 3306<br />socket= /tmp/mysql.sock<br />skip-locking<br />key_buffer = 256M<br />max_allowed_packet = 1M<br />table_cache = 256<br />sort_buffer_size = 1M<br />read_buffer_size = 1M<br />read_rnd_buffer_size = 4M<br />myisam_sort_buffer_size = 64M<br />thread_cache_size = 8<br />query_cache_size= 16M<br /># Try number of CPU's*2 for thread_concurrency<br />thread_concurrency = 8<br /># Don't listen on a TCP/IP port at all. This can be a security enhancement,<br /># if all processes that need to connect to mysqld run on the same host.<br /># All interaction with mysqld must be made via Unix sockets or named pipes.<br /># Note that using this option without enabling named pipes on Windows<br /># (via the "enable-named-pipe" option) will render mysqld useless!<br />#<br />#skip-networking<br /># Replication Master Server (default)<br /># binary logging is required for replication<br />log-bin=mysql-bin<br /># required unique id between 1 and 2^32 - 1<br /># defaults to 1 if master-host is not set<br /># but will not function as a master if omitted<br />server-id= 1<br /># Replication Slave (comment out master section to use this)<br />#<br /># To configure this host as a replication slave, you can choose between<br /># two methods :<br />#<br /># 1) Use the CHANGE MASTER TO command (fully described in our manual) -<br /># the syntax is:<br />#<br /># CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,<br /># MASTER_USER=<user>, MASTER_PASSWORD=<password> ;<br />#<br /># where you replace <host>, <user>, <password> by quoted strings and<br /># <port> by the master's port number (3306 by default).<br />#<br /># Example:<br />#<br /># CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,<br /># MASTER_USER='joe', MASTER_PASSWORD='secret';<br />#<br /># OR<br />#<br /># 2) Set the variables below. However, in case you choose this method, then<br /># start replication for the first time (even unsuccessfully, for example<br /># if you mistyped the password in master-password and the slave fails to<br /># connect), the slave will create a master.info file, and any later<br /># change in this file to the variables' values below will be ignored and<br /># overridden by the content of the master.info file, unless you shutdown<br /># the slave server, delete master.info and restart the slaver server.<br /># For that reason, you may want to leave the lines below untouched<br /># (commented) and instead use CHANGE MASTER TO (see above)<br />#<br /># required unique id between 2 and 2^32 - 1<br /># (and different from the master)<br /># defaults to 2 if master-host is set<br /># but will not function as a slave if omitted<br />#server-id = 2<br />#<br /># The replication master for this slave - required<br />#master-host = <hostname><br />#<br /># The username the slave will use for authentication when connecting<br /># to the master - required<br />#master-user = <username><br />#<br /># The password the slave will authenticate with when connecting to<br /># the master - required<br />#master-password = <password><br />#<br /># The port the master is listening on.<br /># optional - defaults to 3306<br />#master-port = <port><br />#<br /># binary logging - not required for slaves, but recommended<br />#log-bin=mysql-bin<br /># Point the following paths to different dedicated disks<br />#tmpdir= /tmp/<br />#log-update = /path-to-dedicated-directory/hostname<br /># Uncomment the following if you are using BDB tables<br />#bdb_cache_size = 256M<br />#bdb_max_lock = 100000<br /># Uncomment the following if you are using InnoDB tables<br />#innodb_data_home_dir = /usr/local/var/<br />#innodb_data_file_path = ibdata1:10M:autoextend<br />#innodb_log_group_home_dir = /usr/local/var/<br />#innodb_log_arch_dir = /usr/local/var/<br /># You can set .._buffer_pool_size up to 50 - 80 %<br /># of RAM but beware of setting memory usage too high<br />#innodb_buffer_pool_size = 256M<br />#innodb_additional_mem_pool_size = 20M<br /># Set .._log_file_size to 25 % of buffer pool size<br />#innodb_log_file_size = 64M<br />#innodb_log_buffer_size = 8M<br />#innodb_flush_log_at_trx_commit = 1<br />#innodb_lock_wait_timeout = 50<br />[mysqldump]<br />quick<br />max_allowed_packet = 16M<br />[mysql]<br />no-auto-rehash<br /># Remove the next comment character if you are not familiar with SQL<br />#safe-updates<br />[isamchk]<br />key_buffer = 128M<br />sort_buffer_size = 128M<br />read_buffer = 2M<br />write_buffer = 2M<br />[myisamchk]<br />key_buffer = 128M<br />sort_buffer_size = 128M<br />read_buffer = 2M<br />write_buffer = 2M<br />[mysqlhotcopy]<br />interactive-timeout<br />
其中,起作用的代碼是:
# The MySQL server
[mysqld]
basedir="C:/Program Files/cosl_ZWL_App/mysql-5.1.6-alpha-win32/"
datadir="C:/Program Files/cosl_ZWL_App/mysql-5.1.6-alpha-win32/data/"
第二步,cmd中執行如下命令:
sc create zwldb binPath= "/"C:/Program Files/cosl_ZWL_App/mysql-5.1.6-alpha-win32/bin/mysqld-nt/" --defaults-file=/"C:/Program Files/cosl_ZWL_App/mysql-5.1.6-alpha-win32/my.ini/" zwldb" displayname= "zwldb" start= auto<br />net start zwldb<br />exit
刪除mysql服務:
net stop zwldb<br />sc delete zwldb<br />exit