Mysql ODBC 5.1 Driver免安装脚本
2016-03-18 01:23
573 查看
在使用Mysql 的时候,需要使用ODBC数据源的方式来连接mysql,所以常常需要用到免安装的驱动,自己参考官网的脚本,
修改了一个实用点的脚本,放出来大家一起分享:
安装mysql odbc 5.1 Driver
[cpp] view plain copy
@ECHO OFF
SET installdir=none
IF EXIST %windir%/system/nul SET installdir=%windir%/system
IF EXIST %windir%/system32/nul SET installdir=%windir%/system32
IF %installdir%==none GOTO :doError5
IF EXIST %installdir%/myodbc-installer.exe GOTO :doError4
REM ****
REM * Find out the bin/lib directory, or use default
REM ****
SET libdir=lib
SET bindir=bin
IF EXIST lib/release/myodbc5.lib SET libdir=lib/release
IF EXIST lib/relwithdebinfo/myodbc5.lib SET libdir=lib/relwithdebinfo
IF EXIST bin/release/myodbc-installer.exe SET bindir=bin/release
IF EXIST bin/relwithdebinfo/myodbc-installer.exe SET bindir=bin/relwithdebinfo
REM ****
REM * Copying myodbc libraries and executables to install dir...
REM ****
ECHO Copying installation files
IF NOT EXIST %libdir%/myodbc5.lib GOTO :doError2
IF NOT EXIST %libdir%/myodbc5S.lib GOTO :doError2
IF NOT EXIST %bindir%/myodbc-installer.exe GOTO :doError2
copy %libdir%/myodbc5S.dll %installdir%
copy %libdir%/myodbc5S.lib %installdir%
copy %libdir%/myodbc5.dll %installdir%
copy %libdir%/myodbc5.lib %installdir%
copy %bindir%/myodbc-installer.exe %installdir%
copy doc/*.hlp %installdir%
REM ****
REM * Registering driver...
REM *
REM * We can do this with myodbc-installer.exe or the MS Windows ODBCConf.exe. It
REM * may be safer to use the ODBCConf.exe when we think about such things
REM * as 64bit windows.
REM ****
ECHO Registering driver
myodbc-installer -d -a -n "MySQL ODBC 5.1 Driver" -t "DRIVER=myodbc5.dll;SETUP=myodbc5S.dll"
ECHO "+-----------------------------------------------------+"
ECHO "| DONE |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Hopefully things went well; the Connector/ODBC |"
ECHO "| files have been copied to the system directory |"
ECHO "| and the driver has been registered. |"
ECHO "| |"
ECHO "| Connector/ODBC is ready to use. |"
ECHO "| |"
ECHO "| The most common thing to do next is to go to the |"
ECHO "| Control Panel and find the ODBC Administrator - |"
ECHO "| then use it to create a Data Source Name (DSN) |"
ECHO "| so you (and your application) can connect to a |"
ECHO "| MySQL server. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
EXIT /B 0
:doError2
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Connector/ODBC not built. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1
:doError4
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Existing Connector/ODBC installed. Request ignored. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1
:doError5
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Can't find the Windows system directory |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1
卸载部分
[cpp] view plain copy
@ECHO OFF
REM #########################################################
REM
REM /brief Uninstall myodbc.
REM
REM This exists for those working with the Windows source
REM distribution.
REM
REM Use this to remove the driver and supporting files
REM from the system directory and deregister the driver.
REM
REM /sa README.win
REM
REM #########################################################
SET installdir=none
IF EXIST %windir%/system/nul SET installdir=%windir%/system
IF EXIST %windir%/system32/nul SET installdir=%windir%/system32
IF %installdir%==none GOTO :doError4
IF NOT EXIST %installdir%/myodbc-installer.exe GOTO doError2
REM ****
REM * Deregistering driver...
REM ****
myodbc-installer -d -r -n "MySQL ODBC 5.1 Driver"
REM ****
REM * Removing files...
REM ****
del /Q /F %installdir%/myodbc5S.dll
del /Q /F %installdir%/myodbc5S.lib
del /Q /F %installdir%/myodbc5.dll
del /Q /F %installdir%/myodbc5.lib
del /Q /F %installdir%/myodbc-installer.exe
del /Q /F %installdir%/myodbc3*.hlp
ECHO "+-----------------------------------------------------+"
ECHO "| DONE |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Hopefully things went well; the Connector/ODBC |"
ECHO "| files have been removed from the system directory |"
ECHO "| and the driver has been deregistered. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
EXIT /B 0
:doError2
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Connector/ODBC does not appear to be installed. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1
:doError4
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Can't find the Windows system directory |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1
关键部分都带有注释,如有问题欢迎大家一起讨论。
同时附已经做好的mysql odbc 5.1 Driver免安装包
mysql odbc 5.1 Driver
http://blog.csdn.net/blpluto/article/details/5677487
修改了一个实用点的脚本,放出来大家一起分享:
安装mysql odbc 5.1 Driver
[cpp] view plain copy
@ECHO OFF
SET installdir=none
IF EXIST %windir%/system/nul SET installdir=%windir%/system
IF EXIST %windir%/system32/nul SET installdir=%windir%/system32
IF %installdir%==none GOTO :doError5
IF EXIST %installdir%/myodbc-installer.exe GOTO :doError4
REM ****
REM * Find out the bin/lib directory, or use default
REM ****
SET libdir=lib
SET bindir=bin
IF EXIST lib/release/myodbc5.lib SET libdir=lib/release
IF EXIST lib/relwithdebinfo/myodbc5.lib SET libdir=lib/relwithdebinfo
IF EXIST bin/release/myodbc-installer.exe SET bindir=bin/release
IF EXIST bin/relwithdebinfo/myodbc-installer.exe SET bindir=bin/relwithdebinfo
REM ****
REM * Copying myodbc libraries and executables to install dir...
REM ****
ECHO Copying installation files
IF NOT EXIST %libdir%/myodbc5.lib GOTO :doError2
IF NOT EXIST %libdir%/myodbc5S.lib GOTO :doError2
IF NOT EXIST %bindir%/myodbc-installer.exe GOTO :doError2
copy %libdir%/myodbc5S.dll %installdir%
copy %libdir%/myodbc5S.lib %installdir%
copy %libdir%/myodbc5.dll %installdir%
copy %libdir%/myodbc5.lib %installdir%
copy %bindir%/myodbc-installer.exe %installdir%
copy doc/*.hlp %installdir%
REM ****
REM * Registering driver...
REM *
REM * We can do this with myodbc-installer.exe or the MS Windows ODBCConf.exe. It
REM * may be safer to use the ODBCConf.exe when we think about such things
REM * as 64bit windows.
REM ****
ECHO Registering driver
myodbc-installer -d -a -n "MySQL ODBC 5.1 Driver" -t "DRIVER=myodbc5.dll;SETUP=myodbc5S.dll"
ECHO "+-----------------------------------------------------+"
ECHO "| DONE |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Hopefully things went well; the Connector/ODBC |"
ECHO "| files have been copied to the system directory |"
ECHO "| and the driver has been registered. |"
ECHO "| |"
ECHO "| Connector/ODBC is ready to use. |"
ECHO "| |"
ECHO "| The most common thing to do next is to go to the |"
ECHO "| Control Panel and find the ODBC Administrator - |"
ECHO "| then use it to create a Data Source Name (DSN) |"
ECHO "| so you (and your application) can connect to a |"
ECHO "| MySQL server. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
EXIT /B 0
:doError2
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Connector/ODBC not built. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1
:doError4
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Existing Connector/ODBC installed. Request ignored. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1
:doError5
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Can't find the Windows system directory |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1
卸载部分
[cpp] view plain copy
@ECHO OFF
REM #########################################################
REM
REM /brief Uninstall myodbc.
REM
REM This exists for those working with the Windows source
REM distribution.
REM
REM Use this to remove the driver and supporting files
REM from the system directory and deregister the driver.
REM
REM /sa README.win
REM
REM #########################################################
SET installdir=none
IF EXIST %windir%/system/nul SET installdir=%windir%/system
IF EXIST %windir%/system32/nul SET installdir=%windir%/system32
IF %installdir%==none GOTO :doError4
IF NOT EXIST %installdir%/myodbc-installer.exe GOTO doError2
REM ****
REM * Deregistering driver...
REM ****
myodbc-installer -d -r -n "MySQL ODBC 5.1 Driver"
REM ****
REM * Removing files...
REM ****
del /Q /F %installdir%/myodbc5S.dll
del /Q /F %installdir%/myodbc5S.lib
del /Q /F %installdir%/myodbc5.dll
del /Q /F %installdir%/myodbc5.lib
del /Q /F %installdir%/myodbc-installer.exe
del /Q /F %installdir%/myodbc3*.hlp
ECHO "+-----------------------------------------------------+"
ECHO "| DONE |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Hopefully things went well; the Connector/ODBC |"
ECHO "| files have been removed from the system directory |"
ECHO "| and the driver has been deregistered. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
EXIT /B 0
:doError2
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Connector/ODBC does not appear to be installed. |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1
:doError4
ECHO "+-----------------------------------------------------+"
ECHO "| ERROR |"
ECHO "+-----------------------------------------------------+"
ECHO "| |"
ECHO "| Can't find the Windows system directory |"
ECHO "| |"
ECHO "+-----------------------------------------------------+"
PAUSE
EXIT /B 1
关键部分都带有注释,如有问题欢迎大家一起讨论。
同时附已经做好的mysql odbc 5.1 Driver免安装包
mysql odbc 5.1 Driver
http://blog.csdn.net/blpluto/article/details/5677487
相关文章推荐
- Mysql免安装版脚本
- win10安装mysql5.6,mysql启动时,闪退
- MYSQL5.7.9开启慢查询日志的技巧
- mysql 中怎么设置默认值为系统日期
- mysql 在各个隔离级别下的锁情况
- 解决mysql 很多只读表的问题
- Ubuntu下安装MySQL遇到的问题及解决措施
- mysqlworkbench画er图
- Mysql 的存储引擎,myisam和innodb的区别。
- Mysql Engine【innodb,myisam】
- MYSQL – TO AVOID ‘Warning: Using a password on the
- mysql 自定义排序函数field()
- 初次学数据库(MySQL)......
- MySQL Replication主从复制—(实例)
- 修改mysql字符集
- MySQL-教学系统数据库设计
- ubuntu 14.04 mysql 主从配置
- mysql索引命中的问题
- MySQL 5.6 for Windows 解压缩版配置安装
- MySQL数据库引擎介绍、区别、创建和性能测试的深入分析