日期:2014-05-16  浏览次数:20730 次

MYSQL 启动管理脚本工具
mysqlm.bat
---------------------------

@echo off
setlocal

REM 首次使用需要配置settings下对应属性.

:settings
set mysql_bin_dir=E:\bisoft\mysql5.1\bin

set user=root
set password=root
set host=localhost
set port=3306
set server=mysqld.exe
set shutdown=mysqladmin.exe shutdown
set client=mysql.exe

:usage
echo.
echo ==========================================================================
echo 	MySQL 数据库服务器管理工具 by amos_tl [11/05/01] 	
echo.
echo 		启动服务器(s) 
echo 		关闭服务器(e) 
echo 		启动客户端(c)
echo 		帮助(h)
echo 		退出(q)
echo.
echo ==========================================================================
echo.

:main
set /p command=(%0):

if "%command%"=="s" echo 启动MySQL服务器... & goto startServer
if "%command%"=="e" echo 关闭MySQL服务器... & goto stopServer
if "%command%"=="c" echo 启动MySQL客户端... & goto startClient
if "%command%"=="h" goto usage
if "%command%"=="q" goto end

goto main

:startServer
start /MIN /B %mysql_bin_dir%\%server%
if %errorlevel% == 0 echo MySQL服务器已启动
if %errorlevel% == 1 echo MySQL服务器启动失败!
goto main

:startClient
start /MIN %mysql_bin_dir%\%client% -h %host% -P %port% -u %user% -p%password%
goto main

:stopServer
call %mysql_bin_dir%\%shutdown% -h %host% -P %port% -u %user% -p%password%
if %errorlevel% == 0 echo MySQL服务器已停止
if %errorlevel% == 1 echo MySQL服务器停止失败!
goto main

:end
endlocal
exit



mysql 修改root用户密码:

mysql -u root -p

use mysql

update user set password=PASSWORD('123456') where host = 'localhost' and user = 'root';

flush privileges;