在使用Mysql 的时候,需要使用ODBC数据源的方式来连接mysql,所以常常需要用到免安装的驱动,自己参考官网的脚本,

修改了一个实用点的脚本,放出来大家一起分享:

安装mysql odbc 5.1 Driver

  1. @ECHO OFF
  2. SET installdir=none
  3. IF EXIST %windir%/system/nul   SET installdir=%windir%/system
  4. IF EXIST %windir%/system32/nul SET installdir=%windir%/system32
  5. IF %installdir%==none GOTO :doError5
  6. IF EXIST %installdir%/myodbc-installer.exe GOTO :doError4
  7. REM ****
  8. REM * Find out the bin/lib directory, or use default
  9. REM ****
  10. SET libdir=lib
  11. SET bindir=bin
  12. IF EXIST lib/release/myodbc5.lib         SET libdir=lib/release
  13. IF EXIST lib/relwithdebinfo/myodbc5.lib  SET libdir=lib/relwithdebinfo
  14. IF EXIST bin/release/myodbc-installer.exe        SET bindir=bin/release
  15. IF EXIST bin/relwithdebinfo/myodbc-installer.exe SET bindir=bin/relwithdebinfo
  16. REM ****
  17. REM * Copying myodbc libraries and executables to install dir...
  18. REM ****
  19. ECHO Copying installation files
  20. IF NOT EXIST %libdir%/myodbc5.lib  GOTO :doError2
  21. IF NOT EXIST %libdir%/myodbc5S.lib GOTO :doError2
  22. IF NOT EXIST %bindir%/myodbc-installer.exe GOTO :doError2
  23. copy %libdir%/myodbc5S.dll %installdir%
  24. copy %libdir%/myodbc5S.lib %installdir%
  25. copy %libdir%/myodbc5.dll  %installdir%
  26. copy %libdir%/myodbc5.lib  %installdir%
  27. copy %bindir%/myodbc-installer.exe      %installdir%
  28. copy doc/*.hlp             %installdir%
  29. REM ****
  30. REM * Registering driver...
  31. REM *
  32. REM * We can do this with myodbc-installer.exe or the MS Windows ODBCConf.exe. It
  33. REM * may be safer to use the ODBCConf.exe when we think about such things
  34. REM * as 64bit windows.
  35. REM ****
  36. ECHO Registering driver
  37. myodbc-installer -d -a -n "MySQL ODBC 5.1 Driver" -t "DRIVER=myodbc5.dll;SETUP=myodbc5S.dll"
  38. ECHO "+-----------------------------------------------------+"
  39. ECHO "| DONE                                                |"
  40. ECHO "+-----------------------------------------------------+"
  41. ECHO "|                                                     |"
  42. ECHO "| Hopefully things went well; the Connector/ODBC      |"
  43. ECHO "| files have been copied to the system directory      |"
  44. ECHO "| and the driver has been registered.                 |"
  45. ECHO "|                                                     |"
  46. ECHO "| Connector/ODBC is ready to use.                     |"
  47. ECHO "|                                                     |"
  48. ECHO "| The most common thing to do next is to go to the    |"
  49. ECHO "| Control Panel and find the ODBC Administrator -     |"
  50. ECHO "| then use it to create a Data Source Name (DSN)      |"
  51. ECHO "| so you (and your application) can connect to a      |"
  52. ECHO "| MySQL server.                                       |"
  53. ECHO "|                                                     |"
  54. ECHO "+-----------------------------------------------------+"
  55. EXIT /B 0
  56. :doError2
  57. ECHO "+-----------------------------------------------------+"
  58. ECHO "| ERROR                                               |"
  59. ECHO "+-----------------------------------------------------+"
  60. ECHO "|                                                     |"
  61. ECHO "| Connector/ODBC not built.                           |"
  62. ECHO "|                                                     |"
  63. ECHO "+-----------------------------------------------------+"
  64. PAUSE
  65. EXIT /B 1
  66. :doError4
  67. ECHO "+-----------------------------------------------------+"
  68. ECHO "| ERROR                                               |"
  69. ECHO "+-----------------------------------------------------+"
  70. ECHO "|                                                     |"
  71. ECHO "| Existing Connector/ODBC installed. Request ignored. |"
  72. ECHO "|                                                     |"
  73. ECHO "+-----------------------------------------------------+"
  74. PAUSE
  75. EXIT /B 1
  76. :doError5
  77. ECHO "+-----------------------------------------------------+"
  78. ECHO "| ERROR                                               |"
  79. ECHO "+-----------------------------------------------------+"
  80. ECHO "|                                                     |"
  81. ECHO "| Can't find the Windows system directory             |"
  82. ECHO "|                                                     |"
  83. ECHO "+-----------------------------------------------------+"
  84. PAUSE
  85. EXIT /B 1

卸载部分

  1. @ECHO OFF
  2. REM #########################################################
  3. REM
  4. REM /brief  Uninstall myodbc.
  5. REM
  6. REM         This exists for those working with the Windows source
  7. REM         distribution.
  8. REM
  9. REM         Use this to remove the driver and supporting files
  10. REM         from the system directory and deregister the driver.
  11. REM
  12. REM /sa     README.win
  13. REM
  14. REM #########################################################
  15. SET installdir=none
  16. IF EXIST %windir%/system/nul   SET installdir=%windir%/system
  17. IF EXIST %windir%/system32/nul SET installdir=%windir%/system32
  18. IF %installdir%==none GOTO :doError4
  19. IF NOT EXIST %installdir%/myodbc-installer.exe GOTO doError2
  20. REM ****
  21. REM * Deregistering driver...
  22. REM ****
  23. myodbc-installer -d -r -n "MySQL ODBC 5.1 Driver"
  24. REM ****
  25. REM * Removing files...
  26. REM ****
  27. del /Q /F %installdir%/myodbc5S.dll
  28. del /Q /F %installdir%/myodbc5S.lib
  29. del /Q /F %installdir%/myodbc5.dll
  30. del /Q /F %installdir%/myodbc5.lib
  31. del /Q /F %installdir%/myodbc-installer.exe
  32. del /Q /F %installdir%/myodbc3*.hlp
  33. ECHO "+-----------------------------------------------------+"
  34. ECHO "| DONE                                                |"
  35. ECHO "+-----------------------------------------------------+"
  36. ECHO "|                                                     |"
  37. ECHO "| Hopefully things went well; the Connector/ODBC      |"
  38. ECHO "| files have been removed from the system directory   |"
  39. ECHO "| and the driver has been deregistered.               |"
  40. ECHO "|                                                     |"
  41. ECHO "+-----------------------------------------------------+"
  42. EXIT /B 0
  43. :doError2
  44. ECHO "+-----------------------------------------------------+"
  45. ECHO "| ERROR                                               |"
  46. ECHO "+-----------------------------------------------------+"
  47. ECHO "|                                                     |"
  48. ECHO "| Connector/ODBC does not appear to be installed.     |"
  49. ECHO "|                                                     |"
  50. ECHO "+-----------------------------------------------------+"
  51. PAUSE
  52. EXIT /B 1
  53. :doError4
  54. ECHO "+-----------------------------------------------------+"
  55. ECHO "| ERROR                                               |"
  56. ECHO "+-----------------------------------------------------+"
  57. ECHO "|                                                     |"
  58. ECHO "| Can't find the Windows system directory             |"
  59. ECHO "|                                                     |"
  60. ECHO "+-----------------------------------------------------+"
  61. PAUSE
  62. 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免安装脚本的更多相关文章

  1. MySQL ODBC 3.51 Driver - Access Denied

    MySQL ODBC 3.51 Driver - Access Denied   同事反馈在应用服务器上配置MySQL ODBC 3.51 Drive时,测试连接MySQL数据库时报下面错误: ERR ...

  2. 【MYSQL】mysql-5.6.19-win32免安装版本配置方法

    [MYSQL]mysql-5.6.19-win32免安装版本配置方法 1.文件下载网站(http://dev.mysql.com/downloads/): 具体下载地址:http://211.136. ...

  3. mysql 自动备份和nginx自动安装脚本

    一.自动备份Mysql脚本: 如下脚本为mysql自动备份脚本,仅供参考,可以根据实际情况修改. #!/bin/sh #auto backup mysql #wugk #Define PATH定义变量 ...

  4. 新版本MySQL Server 5.7的免安装版本设置

    今天重新配置电脑,安装java开发运行的相关环境,在安装mysql的过程中,遇到了一些问题. 因为在网站上下载的是免安装版本的mysql 5.7 ,所以在安装过程中只需要解压缩zip的压缩包即可. 之 ...

  5. Mysql在windows下的免安装配置步骤和重新安装的步骤

    windows下mysql免安装配置 1. 下载mysql免安装压缩包 下载mysql-5.6.22-winx64.zip 解压到本地D:\mysql-5.6.22-winx64 2. 修改配置文件 ...

  6. Mysql 5.7 for windows 免安装版(解压版)安装和配置

    网上写的不近详细,这里重新整理下. 准备: 1.windows操作系统 2.mysql 的解压版压缩文件 第一步: 解压mysql的压缩包到你的安装目录,因为是虚拟机,这里我就安装在C盘下:C:\my ...

  7. MySql 5.7.20版本免安装版配置过程

    下载地址为: https://dev.mysql.com/downloads/mysql/ 最下面根据自己的操作系统选择合适的型号 下载完以后解压缩到自定义的路径.这里注意的是路径中不要存在中文. 解 ...

  8. MySQL Server 5.5.44免安装版配置详解

    转载地址:http://wenku.baidu.com/view/2a8bfe6a25c52cc58bd6beff.html### 一 下载MySQL http://dev.mysql.com/dow ...

  9. windows下mysql免安装版配置(踩过的坑)简记

    下载 从官网(https://dev.mysql.com/downloads/mysql/)下载 这里的免安装版本的,相对来说干净,但是需要自己来配置很多东西. 配置 首先是注册windows的服务. ...

随机推荐

  1. Jsp分页实例---假分页

    今天总结一个JSP假分页的实例,由基本功能由js实现. 相较前一篇真分页中程序的功能,丰富了一些.具备首页尾页,和页面跳转功能. 首先还是来总结一下真假分页的优缺点和特性吧. 假分页:从数据库中取出所 ...

  2. 1 #安装php

    #安装php #备注:php5..3以后的版本源码不需要打php-fpm补丁,该补丁已经集成进5..3中强制启用fastcgi. [root@dba01 nginx-]# cd [root@dba01 ...

  3. linux下Python网络编程框架-Twisted安装

    Twisted是python下的用来进行网络服务和应用程序编程的框架,安装Twisted前需要系统预先安装有python. 一.安装Twisted http://twistedmatrix.com/R ...

  4. SuperSocket源码解析之会话生命周期

    一 基本概念 会话(Session)是客户端与服务器进行通信的基本单元,也是一个Socket的封装,在http协议中也有Session机制,其主要作用封装一个通信单元socket,负责服务器与客户端消 ...

  5. 从 Qt 的 delete 说开来

    原地址:http://blog.csdn.net/dbzhang800/article/details/6300025 在C++中学习过程中,我们都知道: delete 和 new 必须 配对使用(一 ...

  6. MvvmLight Messenger(信使)

    MvvmLight信使需要三个部分: 1.自定义信件类,普通的Model,供在发布者和订阅者之间传递信息用. 2.发布,通常是在某一事件函数中进行发布,Messenger.Default.Send 3 ...

  7. WPF4字体改善

    原文 WPF4字体改善 WPF4对字体渲染做了很大的改善,增加了TextOptions属性,该属性可以设置TextFormattingMode,TextRenderingMode,TextHintin ...

  8. 基于visual Studio2013解决C语言竞赛题之0614递归大元素

     题目 解决代码及点评 /************************************************************************/ /* 14. 编一个程 ...

  9. java调用163邮箱发送邮件

    1:注册一个163邮箱,http://mail.163.com 调用发送邮件代码,查询smtp.163.com,作为发送邮件的服务器ip,类似的邮箱服务器应该也可以. MailSenderInfo m ...

  10. 高斯拉普拉斯算子(Laplace of Gaussian)

    高斯拉普拉斯(Laplace of Gaussian) kezunhai@gmail.com http://blog.csdn.net/kezunhai Laplace算子作为一种优秀的边缘检测算子, ...