Batch command--Configure the install-free MySQL 5.6.22

Source: Internet
Author: User
Tags file copy

Original: Batch command--Configure the install-free MySQL

The free-to-install version of MySQL is an excellent assistant for Software Green Publishing, and this article describes a method for automating the configuration of MySQL using batch commands.
(1) Establish three files, respectively: Service Install.bat,temp.txt,update.sql.
(2) write the following in the Temp.txt file:
Set pathtemp=
(3) write the following in the Update.sql file:
Use MySQL
Update user set host= '% ' where user= ' root ' and host= ' 127.0.0.1 ';
Update user set Password=password (' root ') where user= ' root ' and host= '% ';
Quit
(4) write the following in the service Install.bat file:

@echo offnet Stop Mysqlrem The effect of @echo off is to turn off the Echo function rem Find the current path REM will copy the contents of the Temp.txt file into the Temp.bat file the content in the REM temp.txt file is "set Pathtemp="REM Special attention:"="cannot be added back to copy temp.txt Temp.batrem to add the path to the Temp.bat file CD>>Temp.batrem Execute temp.bat file in the command rem temp.bat file after execution, the path has been saved in the PATHTEMP variable call temp.batrem delete temp.bat file del temp.batrem copy my -default.ini file copy my-Default.ini My.inirem Setting the tag bit of the My.ini set tag=[Mysqld]rem Set the database path and data path added to the My.ini file rem set DataDir=datadir=%pathtemp%\data means: REM will string "DataDir=, the string corresponding to the variable pathtemp and the string "\data" are assigned to the DATADIR variable set basedir=basedir=%pathtemp%Set DataDir=datadir=%pathtemp%\datarem Setting the Run environment variable Homedirset homedir=%pathtemp%\binrem Setting variable delay REM Note: After using variable delay, related variables with!! Surrounded so that the program can correctly identify the contents of the setlocal Enabledelayedexpansionrem loop to find the My.ini file for/F"tokens=*"%%iinch(My.ini) Do(Rem will be from my-Huge.ini The string that is read in the file, assigned to the variable PSet p=%%Irem If the contents of the variable p and my-Huge.ini the tag bit of the same REM writes the contents of the variable p to the My.ini file, with two lines following it: The content of REM basedir and the content of DataDir; rem if different, write only the contents of the variable p into the My.ini file if "!p!"=="%tag%" (Echo!p!>>My.iniEcho!basedir!>>My.iniEcho!datadir!>>My.ini)ifNot"!p!"=="%tag%" Echo!p!>>my.ini) rem set command to remove MySQL Service set Uninstallcmd=. \bin\mysqld.exe removerem Invoke Delete command call!uninstallcmd!REM SET command to install MySQL service set Installcmd=.\bin\mysqld.exe-Installrem Invoke install command call!installcmd!REM starts the MySQL service net start Mysqlrem calls the SQL statement in the Update.sql file, opens the remote access for MySQL to the remote access server, and REM also changes the MySQL password, This batch command changes the MySQL password to root.\bin\mysql-U Root <. \update.sqlrem Restart MySQL service net stop mysqlnet start Mysqlpause


(5) Run the service Install.bat file to complete the MySQL environment configuration, you can call the MySQL service through the program.

Note: At this point, the root user password for MySQL has been changed to "root" and allows users to access MySQL remotely.

Batch command--Configure the install-free MySQL 5.6.22

Related Article

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.