Mysql ODBC 5.1 Driver免安裝指令碼

來源:互聯網
上載者:User

在使用Mysql 的時候,需要使用ODBC資料來源的方式來串連mysql,所以常常需要用到免安裝的驅動,自己參考官網的指令碼,

 

修改了一個實用點的指令碼,放出來大家一起分享:

 

安裝mysql odbc 5.1 Driver

@ECHO OFF<br />SET installdir=none<br />IF EXIST %windir%/system/nul SET installdir=%windir%/system<br />IF EXIST %windir%/system32/nul SET installdir=%windir%/system32<br />IF %installdir%==none GOTO :doError5<br />IF EXIST %installdir%/myodbc-installer.exe GOTO :doError4<br />REM ****<br />REM * Find out the bin/lib directory, or use default<br />REM ****<br />SET libdir=lib<br />SET bindir=bin<br />IF EXIST lib/release/myodbc5.lib SET libdir=lib/release<br />IF EXIST lib/relwithdebinfo/myodbc5.lib SET libdir=lib/relwithdebinfo<br />IF EXIST bin/release/myodbc-installer.exe SET bindir=bin/release<br />IF EXIST bin/relwithdebinfo/myodbc-installer.exe SET bindir=bin/relwithdebinfo<br />REM ****<br />REM * Copying myodbc libraries and executables to install dir...<br />REM ****<br />ECHO Copying installation files<br />IF NOT EXIST %libdir%/myodbc5.lib GOTO :doError2<br />IF NOT EXIST %libdir%/myodbc5S.lib GOTO :doError2<br />IF NOT EXIST %bindir%/myodbc-installer.exe GOTO :doError2<br />copy %libdir%/myodbc5S.dll %installdir%<br />copy %libdir%/myodbc5S.lib %installdir%<br />copy %libdir%/myodbc5.dll %installdir%<br />copy %libdir%/myodbc5.lib %installdir%<br />copy %bindir%/myodbc-installer.exe %installdir%<br />copy doc/*.hlp %installdir%<br />REM ****<br />REM * Registering driver...<br />REM *<br />REM * We can do this with myodbc-installer.exe or the MS Windows ODBCConf.exe. It<br />REM * may be safer to use the ODBCConf.exe when we think about such things<br />REM * as 64bit windows.<br />REM ****<br />ECHO Registering driver<br />myodbc-installer -d -a -n "MySQL ODBC 5.1 Driver" -t "DRIVER=myodbc5.dll;SETUP=myodbc5S.dll"<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| DONE |"<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| |"<br />ECHO "| Hopefully things went well; the Connector/ODBC |"<br />ECHO "| files have been copied to the system directory |"<br />ECHO "| and the driver has been registered. |"<br />ECHO "| |"<br />ECHO "| Connector/ODBC is ready to use. |"<br />ECHO "| |"<br />ECHO "| The most common thing to do next is to go to the |"<br />ECHO "| Control Panel and find the ODBC Administrator - |"<br />ECHO "| then use it to create a Data Source Name (DSN) |"<br />ECHO "| so you (and your application) can connect to a |"<br />ECHO "| MySQL server. |"<br />ECHO "| |"<br />ECHO "+-----------------------------------------------------+"<br />EXIT /B 0<br />:doError2<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| ERROR |"<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| |"<br />ECHO "| Connector/ODBC not built. |"<br />ECHO "| |"<br />ECHO "+-----------------------------------------------------+"<br />PAUSE<br />EXIT /B 1<br />:doError4<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| ERROR |"<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| |"<br />ECHO "| Existing Connector/ODBC installed. Request ignored. |"<br />ECHO "| |"<br />ECHO "+-----------------------------------------------------+"<br />PAUSE<br />EXIT /B 1<br />:doError5<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| ERROR |"<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| |"<br />ECHO "| Can't find the Windows system directory |"<br />ECHO "| |"<br />ECHO "+-----------------------------------------------------+"<br />PAUSE<br />EXIT /B 1<br /> 

 

卸載部分

@ECHO OFF<br />REM #########################################################<br />REM<br />REM /brief Uninstall myodbc.<br />REM<br />REM This exists for those working with the Windows source<br />REM distribution.<br />REM<br />REM Use this to remove the driver and supporting files<br />REM from the system directory and deregister the driver.<br />REM<br />REM /sa README.win<br />REM<br />REM #########################################################<br />SET installdir=none<br />IF EXIST %windir%/system/nul SET installdir=%windir%/system<br />IF EXIST %windir%/system32/nul SET installdir=%windir%/system32<br />IF %installdir%==none GOTO :doError4<br />IF NOT EXIST %installdir%/myodbc-installer.exe GOTO doError2<br />REM ****<br />REM * Deregistering driver...<br />REM ****<br />myodbc-installer -d -r -n "MySQL ODBC 5.1 Driver"<br />REM ****<br />REM * Removing files...<br />REM ****<br />del /Q /F %installdir%/myodbc5S.dll<br />del /Q /F %installdir%/myodbc5S.lib<br />del /Q /F %installdir%/myodbc5.dll<br />del /Q /F %installdir%/myodbc5.lib<br />del /Q /F %installdir%/myodbc-installer.exe<br />del /Q /F %installdir%/myodbc3*.hlp<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| DONE |"<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| |"<br />ECHO "| Hopefully things went well; the Connector/ODBC |"<br />ECHO "| files have been removed from the system directory |"<br />ECHO "| and the driver has been deregistered. |"<br />ECHO "| |"<br />ECHO "+-----------------------------------------------------+"<br />EXIT /B 0<br />:doError2<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| ERROR |"<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| |"<br />ECHO "| Connector/ODBC does not appear to be installed. |"<br />ECHO "| |"<br />ECHO "+-----------------------------------------------------+"<br />PAUSE<br />EXIT /B 1<br />:doError4<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| ERROR |"<br />ECHO "+-----------------------------------------------------+"<br />ECHO "| |"<br />ECHO "| Can't find the Windows system directory |"<br />ECHO "| |"<br />ECHO "+-----------------------------------------------------+"<br />PAUSE<br />EXIT /B 1<br /> 

 

關鍵區段都帶有注釋,如有問題歡迎大家一起討論。

 

同時附已經做好的mysql odbc 5.1 Driver免安裝包

 

mysql odbc 5.1 Driver

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.