Linux mysql connector odbc

How to Install the MySQL ODBC Driver on Ubuntu 16.04?

The seemingly easy task to install the MySQL ODBC driver on Ubuntu 16.04 has turned out to be a challenge. It has resulted from the driver upgrade problem that Ubuntu developers couldn’t have handled.

If you have the latest version of Ubuntu 16.04 installed on your system, you may have already hit a snag while attempting to locate the ODBC driver.

# apt-get install libmyodbc Reading package lists. Done Building dependency tree Reading state information. Done Package libmyodbc is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package ‘libmyodbc’ has no installation candidate

Prior to that MySQL could be accessed via ODBC-based applications, after having the ODBC driver installed using a simple Terminal command:

As for the latest version, all efforts to search the Ubuntu repository for the ODBC driver are in vain: of all the repositories listed in the software sources, none of them include the libmyodbc package. According to the Ubuntu version history, the package used to exist but has been deleted due to a certain bug.

MySQL 5.7, as opposed to other versions, restricts symbols available in libmysqlclient20. It looks like MyODBC uses some of these symbols, so it cannot be installed from libmysqlclient-dev.

In fact, maintaining MyODBC in Ubuntu is a disputable question, since there are no hard dependencies on it, and it is a default alternative for libreoffice-canzeley-client.

Thus, MyODBC that uses libmysqlclient functions incompatible with MySQL 5.7 is not supported by Ubuntu 16.04 at the moment. Once the work on MySQL 5.7 is finished, Ubuntu developers may get it back into the release. However, there is a chance it is never going to happen.

If you have software that absolutely requires the MySQL ODBC driver, it is possible to set one up and get it working on Ubuntu 16.04. To do it, take the following steps:

  1. Download the ODBC driver for Ubuntu 15.10 (mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit.tar.gz) from this page.
  2. Extract the files: tar -xvf mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit.tar.gz
  3. Copy the driver to the ODBC folder: sudo cp mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit/lib/libmyodbc5* /usr/lib/x86_64-linux-gnu/odbc/
  4. Install it: sudo mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit/bin/myodbc-installer -d -a -n «MySQL» -t «DRIVER=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5w.so;»
  1. Create DSN: sudo mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit/bin/myodbc-installer -s -a -c2 -n «test» -t «DRIVER=MySQL;SERVER=127.0.0.1;DATABASE=mysql;UID=root;PWD=123456»
  2. Сonnect the database and query it:
[email protected]:~$ isql test +—————————————+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +—————————————+ SQL> show tables +——————————————————————+ | Tables_in_mysql | +——————————————————————+ | columns_priv | | db | | engine_cost | | event | | func | ………. +——————————————————————+
[email protected]:~$ cat /etc/odbc.ini [test] Driver=MySQL SERVER=127.0.0.1 UID=root PWD=123456 DATABASE=mysql PORT=3306 [email protected]:~$ cat /etc/odbcinst.ini [MySQL] Driver=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5w.so UsageCount=1

The ODBC driver for MySQL is installed. Your software now has an opportunity to establish connection with MySQL directly via TCP/IP.

Next, does your MySQL or other database contains a sensitive data that has to be secured and protected? Or do you need to be in compliance with GDPR, SOX or HIPAA? Check DataSunrise database security and data masking software or download the trial.

Источник

Подготовка ODBC драйвера для подключения к MySQL

Для корректного подключения к базам данных MySQL необходима установка драйверов ODBC. Поддерживается выполнение только запросов, команд СУБД. Создание и использование таблиц, представлений, процедур и функций поддерживается в зависимости от возможностей конкретной СУБД и её соответствия стандартам SQL.

В данной статье приведен пример создания базы данных, таблицы и пользователя для подключения к MySQL с помощью драйвера Connector/ODBC на Ubuntu 18.04.

Предварительно необходимо установить клиентскую и серверную части MySQL:

sudo apt-get install mysql-server

sudo apt-get install mysql-client

Установить unixodbc и odbcinst, если их нет:

sudo apt-get install unixodbc

sudo apt-get install odbcinst

В Ubuntu 18.04 из официального репозитория была удалена библиотека libmyodbc. В связи с этим установите Connector/ODBC вручную.

Совет . Для MySQL 5.7 рекомендуется скачать MySQL Connector/ODBC 5.3.13.

После подготовки ODBC драйвера установите или перезапустите BI-сервер, если он был установлен ранее.

Установка Connector/ODBC

Рассмотрим пример установки Connector/ODBC на Ubuntu 18.04.

Для установки Connector/ODBC выполните действия:

tar xvf mysql-connector-odbc-5.3.13-linux-ubuntu18.04-x86-64bit.tar

myodbc-installer –a –d –n “MySQL ODBC 5.3 Unicode Driver” –t “Driver=/usr/local/lib/libmyodbc5w.so”

myodbc-installer –a –d –n “MySQL ODBC 5.3 ANSI Driver” –t “Driver=/usr/local/lib/libmyodbc5a.so”

В результате компиляции в терминале должно быть выведено имя зарегистрированных драйверов:

MySQL ODBC 5.3 Unicode Driver

MySQL ODBC 5.3 ANSI Driver

Примечание . Информация о зарегистрированных драйверах хранится в конфигурационном файле /etc/odbcinst.ini.

  1. Отредактируйте файл настроек /etc/mysql/my.cnf или /etc/mysql/mysql.conf.d/mysqld.cnf для подключения к удаленному серверу MySQL. В одном из файлов конфигурации хранится строка:

Для подключения к базе данных с любого IP-адреса замените строку на:

sudo systemctl restart mysql

Создание базы данных, таблицы и пользователя

  1. Создайте базу данных в MySQL с идентификатором test_database.
  2. Создайте таблицу с идентификатором test_table в базе данных и заполните ее значениями от 1 до 10.
  3. Создайте пользователя и предоставьте ему права для подключения к базе данных:

create user ‘test_user’@’%’ identified by ‘123’;

grant all privileges on *.* to ‘test_user’@’%’ identified by ‘123’;

% — означает, что пользователь может подключаться с любого IP-адреса.

sudo myodbc-installer –s –a –c2 –n “TestDSN” –t “DRIVER=MySQL ODBC 5.3 Unicode

При успешном подключении к созданной DSN будет получено следующее сообщение:

Примечание . Созданные DSN хранятся в конфигурационном файле /etc/odbc.ini.

Источник

MySQL Connector/ODBC Developer Guide

This manual describes how to install and configure MySQL Connector/ODBC, the driver that enables ODBC applications to communicate with MySQL servers, and how to use it to develop database applications.

MySQL Connector/ODBC 8.0 is recommended for use with MySQL Server 8.0, 5.7, and 5.6. Please upgrade to MySQL Connector/ODBC 8.0.

For notes detailing the changes in each release of Connector/ODBC, see MySQL Connector/ODBC Release Notes.

For legal information, see the Legal Notices.

For help with using MySQL, please visit the MySQL Forums, where you can discuss your issues with other MySQL users.

Licensing information. This product may include third-party software, used under license. MySQL Connector/ODBC 8.0 Community License Information User Manual has information about licenses relating to Connector/ODBC community releases in the 8.0 release series. MySQL Connector/ODBC 8.0 Commercial License Information User Manual has information about licenses relating to Connector/ODBC commercial releases in the 8.0 release series. MySQL Connector/ODBC Community License Information User Manual has information about licenses relating to Connector/ODBC community releases up to and including version 5.3. MySQL Connector/ODBC Commercial License Information User Manual has information about licenses relating to Connector/ODBC commercial releases up to and including version 5.3.

Document generated on: 2023-06-05 (revision: 75805)

Table of Contents

Оцените статью
Adblock
detector