VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 数据库 > SQL教程 >
  • mysql 通过批处理安装

最近通过实践,已成功通过批处理配置mysql的安装
分享下下面的脚本
if not exist "c:\mysql-5.1.55-win32" (md "c:\mysql-5.1.55-win32")
xcopy "%~dp0*" "c:\mysql-5.1.55-win32" /e /q /h /r /y
@ECHO mysql数据库已安装
@ECHO OFF
if exist "c:\mysql-5.1.55-win32\my.ini" goto startsrv
for /f %%i in ('net start') do if %%i==MySQL goto MySQL_IsRunning
goto MySQL_NotRunning
 
:MySQL_IsRunning
echo "found Server!"
net stop mysql
 
c:\mysql-5.1.55-win32\bin\mysqld.exe -remove
 
goto createmyini
 
:MySQL_NotRunning
echo "not found!"
 
:createmyini
rem -------------------------------------------------------
rem edit my.ini
 
setlocal enabledelayedexpansion
set realpath="c:\mysql-5.1.55-win32"
set replaced=\
set all=/
for /f "delims=" %%i in ('cd') do (
    set str=%%i
    set "str=!str:%replaced%=%all%!"
    set realpath=!str!
)
 
echo [client] >>c:\mysql-5.1.55-win32\my.ini
echo default-character-set=utf8 >>c:\mysql-5.1.55-win32\my.ini
echo port=3306 >>c:\mysql-5.1.55-win32\my.ini
echo [server] >>c:\mysql-5.1.55-win32\my.ini
echo default-character-set=utf8 >>c:\mysql-5.1.55-win32\my.ini
echo port=3306 >>c:\mysql-5.1.55-win32\my.ini
echo [mysql] >>c:\mysql-5.1.55-win32\my.ini
echo default-character-set=utf8 >>c:\mysql-5.1.55-win32\my.ini
 
echo [mysqld] >>c:\mysql-5.1.55-win32\my.ini
echo port=3306 >>c:\mysql-5.1.55-win32\my.ini
echo basedir=c:\mysql-5.1.55-win32>>c:\mysql-5.1.55-win32\my.ini
echo datadir=c:\mysql-5.1.55-win32\data/>>c:\mysql-5.1.55-win32\my.ini
rem echo basedir = "C:\Program Files\MySQL\MySQL">>my.ini
rem echo datadir = "C:\Program Files\MySQL\MySQL\data\">>my.ini
echo default-character-set=utf8 >>c:\mysql-5.1.55-win32\my.ini
echo default-storage-engine=INNODB >>c:\mysql-5.1.55-win32\my.ini
echo max_connections=100 >>c:\mysql-5.1.55-win32\my.ini
echo query_cache_size=8M >>c:\mysql-5.1.55-win32\my.ini
echo table_cache=256 >>c:\mysql-5.1.55-win32\my.ini
echo tmp_table_size=9M >>c:\mysql-5.1.55-win32\my.ini
echo myisam_max_sort_file_size=100G >>c:\mysql-5.1.55-win32\my.ini
echo myisam_max_extra_sort_file_size=100G >>c:\mysql-5.1.55-win32\my.ini
echo myisam_sort_buffer_size=18M >>c:\mysql-5.1.55-win32\my.ini
echo key_buffer_size=11M >>c:\mysql-5.1.55-win32\my.ini
echo read_buffer_size=64K >>c:\mysql-5.1.55-win32\my.ini
echo read_rnd_buffer_size=256K >>c:\mysql-5.1.55-win32\my.ini
echo sort_buffer_size=256K >>c:\mysql-5.1.55-win32\my.ini
echo innodb_additional_mem_pool_size=2M >>c:\mysql-5.1.55-win32\my.ini
echo innodb_flush_log_at_trx_commit=1 >>c:\mysql-5.1.55-win32\my.ini
echo innodb_log_buffer_size=1M >>c:\mysql-5.1.55-win32\my.ini
echo innodb_buffer_pool_size=18M >>c:\mysql-5.1.55-win32\my.ini
echo innodb_log_file_size=5M >>c:\mysql-5.1.55-win32\my.ini
echo innodb_thread_concurrency=8 >>c:\mysql-5.1.55-win32\my.ini
echo sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" >>c:\mysql-5.1.55-win32\my.ini
rem edit my.ini end.
rem ---------------------------------------------------------------
 
c:\mysql-5.1.55-win32\bin\mysqld.exe -install
 
:startsrv
 
net start MySQL
 
 
set user=root
set password=""
@echo on
c:\mysql-5.1.55-win32\bin\mysql -u %user% --password=  < C:/mysql-5.1.55-win32/initCreateDatabase.sql
c:\mysql-5.1.55-win32\bin\mysql -u %user% --password=  < C:/mysql-5.1.55-win32/initGrantUser.sql
 
 
 
 
@echo MySql数据库配置完成
@echo off
@echo on
c:\mysql-5.1.55-win32\bin\mysql --user=basiclevel --password=hie  --database=smartclient<C:/mysql-5.1.55-win32/createTable.sql
 
@echo MySql数据库建表完成
pause
 
 
 
出处:https://www.cnblogs.com/zuifengke/archive/2013/05/17/3084483.html


相关教程