Register and delete MySQL services using BAT

Source: Internet
Author: User

Add MySQL service:

Step 1: add the file "My. ini" in the MySQL root directory. The file content is:

# Example MySQL config file for large systems. <br/> # this is for a large system with memory = 512 m where the system runs mainly <br/> # MySQL. <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/> # 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 foll Ows 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 = 256 m <br/> max_allowed_packet = 1 m <br/> table_cache = 256 <br/> sort_buffer_size = 1 m <br/> read_buf Fer_size = 1 m <br/> read_rnd_buffer_size = 4 m <br/> myisam_sort_buffer_size = 64 m <br/> thread_cache_size = 8 <br/> query_cache_size = 16 m <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 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/> # 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/> # to configure this host as a replication slave, you can choose between <br/> # two methods: <br/> #1) use the change master to command (fully described in our manual)-<br/> # The syntax is: <br/> # change master to master_host = <post>, master_port = <port>, <br/> # master_user = <user>, master_password = <password >;< br/>#< br/> # Where you replace <post>, <user>, <password> by quoted strings and <br/> # <port> by the master's port number (3306 by default ). <br/> # example: <br/> # change master to master_host = '2017. 564.12.1 ', master_port = 3306, <br/> # master_user = 'job', master_password = 'secret '; <br/>#< br/> # or <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/> # 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 = <postname> <br/> # the username the slave will use for authentication when connecting <br/> # To the master-required <br/> # Master-user = <username> <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/> # 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 = 256 m <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: 10 m: 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 = 256 m <br/> # timeout = 20 m <br/> # set .. _ log_file_size to 25% of buffer pool size <br/> # innodb_log_file_size = 64 m <br/> # innodb_log_buffer_size = 8 m <br/> # bytes = 1 <br/> # innodb_lockwait_timeout = 50 <br/> [mysqldump] <br/> quick <br/> max_allowed_packet = 16 m <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 = 128 M <br /> sort_buffer_size = 128 M <br/> read_buffer = 2 m <br/> write_buffer = 2 m <br/> [myisamchk] <br/> key_buffer = 128 M <br/> sort_buffer_size = 128 M <br/> read_buffer = 2 m <br/> write_buffer = 2 m <br/> [mysqlhotcopy] <br/> interactive-Timeout <br/> 

The code that works is:

# The MySQL Server

[Mysqld]

Basedir = "C:/program files/cosl_zwl_apps/mysql-5.1.6-alpha-win32 /"

Datadir = "C:/program files/cosl_zwl_app/mysql-5.1.6-alpha-win32/data /"

Step 2: execute the following command in 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 

 

Delete MySQL service:

 

Net stop zwldb <br/> SC Delete zwldb <br/> exit 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.