Batch command--Configure the install-free MySQL

Source: Internet
Author: User
Tags bit set mysql update

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) writes the following in the Update.sql file: Use MySQL update user set host= '% ' where user= ' root ' and hos t= ' 127.0.0.1 '; Update user set Password=password (' root ') where user= ' root ' and host= '% '; Quit (4) writes the following in the service Install.bat file: The function of @echo off rem @echo off is to turn off the Echo function

REM Find current path REM Copies 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 Note: "=" cannot be added back to copy temp.txt Temp.bat >nul

REM adds the path to the Temp.bat file Cd>>temp.bat

REM Executes the Temp.bat file in the command rem temp.bat file after execution, the path has been saved in the PATHTEMP variable in the call Temp.bat

REM Delete temp.bat file del temp.bat

REM Set My-huge.ini marker bit set TAG=[MYSQLD]

REM Set the database path and data path added to the My.ini file the REM set datadir=datadir=%pathtemp%\data means REM sets the string "Datadir=", the variable pathtemp the corresponding string, and the string " \data "assigns a value to the DATADIR variable set basedir=basedir=%pathtemp% set Datadir=datadir=%pathtemp%\data

REM Set Run environment variable Homedir set Homedir=%pathtemp%\bin

REM Set Variable delay REM NOTE: After using variable delay, related variables are used!! Surrounded, so that the program can correctly identify setlocal enabledelayedexpansion

The REM loop finds the contents of the My-huge.ini file for/f "tokens=*"%%i in (My-huge.ini) does (

REM assigns a string that is read from the My-huge.ini file to the variable p set p=%%i

REM If the contents of the variable p and the My-huge.ini tag bits are the same REM writes the contents of the variable p to the My.ini file, adding two lines after it: the contents of the REM Basedir and the contents of the DataDir; if the REM is different, Writes the contents of the variable p to the My.ini file only if "!p!" = = "%tag%" (Echo!p!>>my.ini echo!basedir!>>my.ini echo!datadir!>>my.ini) if not "!p!" = = "%tag%" Echo!p!>>my.ini)

REM SET command to install MySQL service set Installcmd=.\bin\mysqld-nt.exe-install

REM Invoke install command call!installcmd!

REM Start MySQL service net start MySQL

REM calls the SQL statement in the Update.sql file to open the remote access of MySQL for remote access to the server; REM Also, change the MySQL password, this batch command changes the MySQL password to root. \bin\mysql-u Root <.\update.sql

The REM restart MySQL service net stop mysql net start MySQL (5) runs the service Install.bat file, completing the MySQL environment configuration, which can then be called by the program to the MySQL service.

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

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.