原文地址:http://blog.csdn.net/iihero/article/details/5596401
脚本如下,将其放到解压以后的目录里边执行即可。
- @echo off
- echo "This is a demo script for auto installation of noninstall version of MySQL on Windows. "
- echo "Copyright: iihero@CSDN, when you distribute it, please copy this section above the head."
- echo "================================iiihero@hotmail.com====================================="
- set MYSQL_HOME=%~dp0
- echo MYSQL_HOME=%MYSQL_HOME%
- del /F my.ini
- echo [client] >> my.ini
- echo port = 3306 >> my.ini
- echo default_character_set=gbk >> my.ini
- echo [mysqld] >> my.ini
- echo default_character_set=utf8 >> my.ini
- echo default_storage_engine=InnoDB >> my.ini
- echo basedir=%MYSQL_HOME%>>my.ini
- echo datadir=%MYSQL_HOME%data>> my.ini
- echo innodb_data_file=ibdata1:50M;ibdata2:10M:autoextend >> my.ini
- echo transaction-isolation=READ-COMMITTED >> my.ini
- echo port=3306 >> my.ini
- echo max_allowed_packet = 64M >> my.ini
- echo "my.ini in %MYSQL_HOME% created."
- set PATH=%MYSQL_HOME%/bin;%PATH%
- if exist "%MYSQL_HOME%/bin/mysqld-nt.exe" call mysqld-nt --install-manual mysql55 --defaults-file="%MYSQL_HOME%/my.ini"
- if not exist "%MYSQL_HOME%/bin/mysqld-nt.exe" call mysqld --install-manual mysql55 --defaults-file="%MYSQL_HOME%/my.ini"
继续整理:
随然前边写了一篇用于命令行下安装mysql非安装版。但总觉不够。
我承认自己很懒,每次下载,并手动配置一些东西,很浪费时间。于是做了这么一个东东。
直接将mysql_install_auto.zip解压到某盘,如d://mysql_install_auto下边。
然后进到d:/mysql_install_auto下边,使用命令行执行:
mysql_install.bat <fullversion> [arch] [ROOTDIR] [server_port]
参数:
fullversion, 必须指定, 如5.6.14, 5.1.72, 4.1.22, 5.5.34, 6.0.11-alpha等等
arch, 可选,不指定时,为win32, 有效值可以是win32或者winx64
ROOTDIR, 可选,安装的最终根目录,默认值为d:, 不用带后边的"\".此目录必须事先存在或创建好
server_port, 可选,默认值为3306.
最终生成的服务名为: iihero-<主版本号>
如果你想卸载,也非常简单,先用sc delete iihero-<主版本号>
接着进到%ROOTDIR%\%MYSQL_HOME%, 直接删除整个目录就可以了. 非常方便。
有什么问题,欢迎联系:iiihero AT hotmail.com
http://blog.csdn.net/iihero
http://blog.chinaunix.net/uid/40286.html
http://blog.chinaunix.net/topic/hexiong/
确定一个完整的版本号,比如:5.6.14, 5.1.72, 5.5.34, 如何确定,
访问网址:
http://download.softagency.net/MySQL/Downloads/MySQL-<主版本号>/ (主版本号为5.1, 5.6, 5.5之类)
找到win32.zip, 或者winx64.zip结尾的文件名,比如:mysql-5.5.34-win32.zip, 中间的串:5.5.34就是
完整的版本号.
选定是32位的, 还是64位的,32位用win32, 64位的用winx64, 默认为32位。
由于网站空间实在有限,没地方放附件。我将附件放到CSDN上了,有兴趣的可以去下载试用一下。
下载地址:http://download.csdn.net/detail/iihero/6604375
原来的那个包:http://download.csdn.net/source/2998831,需要修改一些东西才能用。
有什么问题,欢迎发邮件给我。
针对刚上传的包,似乎发现了一些小问题,又改了改,下载完以后,修改: mysql_install.bat 以及my_ini_gen.bat,它们的内容分别如下:
mysql_install.bat:
- @echo off
- set fullversion=%1
- set fullname=""
- set server_default_character_set=default_character_set
- set arch=%2
- set ROOTDIR=%3
- set server_port=%4
- set mysql_dir=""
-
- :: example:
- :: mysql_install.bat 4.1.22
- :: mysql_install.bat 5.0.95 winx64
- :: mysql_install.bat 5.6.14 winx64
- :: mysql_install.bat 5.1.72 winx64
- :: mysql_install.bat 5.5.34 winx64
- :: mysql_install.bat 6.0.11-alpha win32
-
- if "[%fullversion%]" == "[]" goto HELP
- if not "[%fullversion%]" == "[]" goto TOINSTALL
- :HELP
- echo mysql_install.bat ^<fullversion^> [arch] [ROOTDIR] [server_port]
- echo valid ^<fullversion^> :4.1.22, 5.1.xx, 5.5.xx, e.g. 5.1.72, 5.6.14, 6.0.11-alpha etc.
- echo valid xx, you can open http://download.softagency.net/MySQL/Downloads/MySQL-^<major_version^> to find it.
- echo e.g. to get the target fullversion of 5.1, you can open:
- echo http://download.softagency.net/MySQL/Downloads/MySQL-5.1 to get the full name end with winx64.zip or win32.zip.
- echo valid value of arch: win32, winx64
- echo ROOTDIR, the root directory of mysql installation. The default value is d: It should be already existed/created.
- echo default server_port is 3306
- echo Please input valid value of the fullversion.
- goto END
-
- :TOINSTALL
- if "%arch%" == "" set arch=win32
- if "%server_port%" == "" set server_port=3306
- if "[%ROOTDIR%]" == "[]" echo ROOTDIR is not set, will be using default value. && set ROOTDIR=d:
- set version=%fullversion:~0,3%
- echo The major version is: %version%
- set version_arch=%fullversion%-%arch%
- echo The full version with arch is: %version_arch%
- :: 4.1版本只有32位的
- if "%version%" == "4.1" (
- set fullname="mysql-noinstall-%version_arch%"
- set mysql_dir="%ROOTDIR%\mysql-%version_arch%"
- echo You will fetch %fullname% ......
- goto DOWNLOAD
- )
-
- if "%version%" == "5.0" (
- set fullname="mysql-noinstall-%version_arch%"
- set mysql_dir="%ROOTDIR%\mysql-%version_arch%"
- echo You will fetch %fullname% ......
- goto DOWNLOAD
- )
-
- if "%version%" == "5.1" (
- set fullname="mysql-noinstall-%version_arch%"
- set mysql_dir="%ROOTDIR%\mysql-%version_arch%"
- echo You will fetch %fullname% ......
- goto DOWNLOAD
- )
-
- if "%version%" == "5.5" (
- set fullname="mysql-%version_arch%"
- set mysql_dir="%ROOTDIR%\mysql-%version_arch%"
- set server_default_character_set=character_set_server
- echo You will fetch %fullname% ......
- goto DOWNLOAD
- )
-
- if "%version%" == "5.6" (
- set fullname="mysql-%version_arch%"
- set mysql_dir="%ROOTDIR%\mysql-%version_arch%"
- set server_default_character_set=character_set_server
- echo You will fetch %fullname% ......
- goto DOWNLOAD
- )
-
- if "%version%" == "6.0" (
- set fullname="mysql-noinstall-%version_arch%"
- set mysql_dir="%ROOTDIR%\mysql-%version_arch%"
- set server_default_character_set=character_set_server
- echo You will fetch %fullname% ......
- goto DOWNLOAD
- )
-
- :ERROR
- echo the version should be 4.1, 5.0, 5.1, 5.5, 5.6, 6.0 for now!!
-
- :DOWNLOAD
- if not exist %fullname%.zip (
- wget http://download.softagency.net/MySQL/Downloads/MySQL-%version%/%fullname%.zip
- if not exist %fullname%.zip (
- echo download %fullname% error!!
- goto EOF
- )
- )
- if not exist %mysql_dir% (
- 7z x -y -o%ROOTDIR%\ -x!*\data\ib* %fullname%.zip
- )
- copy /Y my_ini_gen.bat %mysql_dir%
- cd /d %mysql_dir%
- :: copy /Y ..\my_ini_gen.bat .
- call my_ini_gen.bat
- :EOF
- echo The installation finished....
- :END
- @echo on
my_ini_gen.bat:
- @echo off
- echo "This is a demo script for auto installation of noninstall version of MySQL on Windows. "
- echo "Copyright: iihero, when you distribute it, please copy this section above the head."
- echo "================================iihero.com====================================="
- set MYSQL_HOME=%~dp0
- echo MYSQL_HOME=%MYSQL_HOME%
- del /F my.ini
- echo [client] >> my.ini
- echo port = %server_port% >> my.ini
- echo default_character_set=gbk >> my.ini
- echo [mysqld] >> my.ini
- echo %server_default_character_set%=utf8 >> my.ini
- echo default_storage_engine=InnoDB >> my.ini
- echo basedir=%MYSQL_HOME%>>my.ini
- echo datadir=%MYSQL_HOME%data>> my.ini
- :: echo innodb_data_file_path=%MYSQL_HOME%data>> my.ini
- echo innodb_data_file=ibdata1:50M;ibdata2:10M:autoextend >> my.ini
- echo transaction-isolation=READ-COMMITTED >> my.ini
- echo port=%server_port% >> my.ini
- echo max_allowed_packet = 64M >> my.ini
- echo "my.ini in %MYSQL_HOME% created."
- set PATH=%MYSQL_HOME%\bin;%PATH%
- echo Forcely delete the service iihero-%version% if existing.
- sc delete iihero-%version%
- if exist "%MYSQL_HOME%\bin\mysqld-nt.exe" call %MYSQL_HOME%\bin\mysqld-nt --install-manual "iihero-%version%" --defaults-file="%MYSQL_HOME%my.ini"
- if not exist "%MYSQL_HOME%\bin\mysqld-nt.exe" call %MYSQL_HOME%\bin\mysqld --install-manual "iihero-%version%" --defaults-file="%MYSQL_HOME%\my.ini"
-
-
- echo .........................................................................................
- echo Finished creating service "iihero-%version%" for mysql-%version_arch%. Please check it in the service panel.
- echo You can use net start iihero-%version% to start the mysql service. Good luck.
- echo If you want to delete the install, just do as below:
- echo 1. If you have started the service, just run: net stop iihero-%version% to stop it.
- echo 2. sc delete iihero-%version% to delete the service
- echo 3. Delete the whole directory of %MYSQL_HOME%
- echo .........................................................................................
将上述两个文件的内容覆盖一下就好。主要是修复路径以及版本号的错误, 支持4.1, 5.0, 5.1, 5.5, 5.6, 6.0主版本的下载及安装。
已经重新上传到:
http://download.csdn.net/detail/iihero/6604375