- Odbc connector mysql linux
- Ubuntu Documentation
- Installing the MySQL Database ODBC Driver
- Installing the Firebird Database ODBC Driver
- MySQL Connector/ODBC Developer Guide
- How to Install the MySQL ODBC Driver on Ubuntu 16.04?
- Настройка в Linux подключения к MariaDB из PHP с помощью ODBC
- ODBC connector
- Установка и подготовка к работе СУБД
- Установка и настройка ODBC
Odbc connector mysql linux
To install the driver from a tarball distribution ( .tar.gz file), download the latest version of the driver for your operating system and follow these steps, substituting the appropriate file and directory names based on the package you download (some of the steps below might require superuser privileges):
Extract the archive:
The extra directory contains two subdirectories, lib and bin . Copy their contents to the proper locations on your system (we use /usr/local/bin and /usr/local/lib in this example; replace them with the destinations of your choice):
The last command copies both the Connector/ODBC ANSI and the Unicode drivers from lib into /usr/local/lib ; if you do not need both, you can just copy the one you want. See Choosing Unicode or ANSI Driver for details.
Finally, register the driver version of your choice (the ANSI version, the Unicode version, or both) with your system’s ODBC manager (for example, iODBC or unixodbc) using the myodbc-installer tool that was included in the package under the bin subdirectory (and is now under the /usr/local/bin directory, if the last step was followed); for example, this registers the Unicode driver with the ODBC manager:
For Connector/ODBC 8.0:
For Connector/ODBC 5.3:
Verify that the driver is installed and registered using the ODBC manager, or the myodbc-installer utility:
Next, see Section 5.5, “Configuring a Connector/ODBC DSN on Unix” on how to configure a DSN for Connector/ODBC.
Источник
Ubuntu Documentation
Needs Expansion
This article is incomplete, and needs to be expanded. More info.
Ubuntu supports ODBC connections to databases (such as a remote MySQL server). Whilst this is not normally useful, The database in OpenOffice can use ODBC connections, and it may be convenient to set one up.
Installing the MySQL Database ODBC Driver
Get the linux MySQL ODBC driver. The console incantation is
apt-get install libmyodbc
and synaptic will provide a similar install.
Now hand edit (or create, if it does not exist already) /etc/odbc.ini
Here’s an example odbc.ini:
It is now possible to connect to the database DBNAME using the ODBC connection odbcname
NB: On Ubuntu Trusty 14.04 LTS (32-bit), replace the Driver value above with /usr/lib/i386-linux-gnu/odbc/libmyodbc.so If you had issues with establishing database connection as an option you may download latest mysql odbc driver and after installing it use this connection string: Login Prompt=False;User Source=localhost;Database=test
Installing the Firebird Database ODBC Driver
The Firebird ODBC driver is not in the Ubuntu repositories so it has to be downloaded from the FirebirdSQL site:
It contains a single file named «libOdbcFb.so». Copy this file to the /usr/lib directory.
Next make sure you have the Firebird client library installed:
apt-get install libfbclient2
Openoffice and probably a few other programs will insist on using a driver named libgds.so for connecting to a Firebird database. A symbolic link will have to be created:
ln -s /usr/lib/libfbclient.so.2 /usr/lib/libgds.so
At this point you are ready to add some entries to the odbc config files. If they don’t already exist you can create them.
Here’s another example odbc.ini:
And the relevant entries for the odbcinst.ini file:
You should now be able to connect to DBNAME from OpenOffice or other programs using the ODBC connection method.
If you fail to connect with described method then try to use this firebird odbc driver and connection strings connection strings installation guide to it.
ODBC (последним исправлял пользователь jordan-sanders 2015-07-24 12:24:13)
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details
Источник
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: 2021-09-23 (revision: 70881)
Источник
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:
apt-get install libmyodbc
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:
- Download the ODBC driver for Ubuntu 15.10 (mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit.tar.gz) from this page.
- Extract the files: tar -xvf mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit.tar.gz
- 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/
- 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;»
Check its functioning:
- 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»
- Сonnect the database and query it:
- You’ll finally get the following file configuration:
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.
Источник
Настройка в Linux подключения к MariaDB из PHP с помощью ODBC
Использование ODBC в PHP позволит делать SQL-запросы независимо от типа СУБД — это может быть MySQL/MariaDB, MS SQL, Sybase, Oracle, PostgreSQL и так далее. Мы рассмотрим подключение к MariaDB. Предложенная инструкция протестирована на Linux Ubuntu и CentOS.
Наши действия разобьем по шагам:
ODBC connector
Для начала мы должны установить ODBC connector. Нам понадобиться скачать на наш сервер архив, поэтому сначала инсталлируем wget.
а) на CentOS / Red Hat:
yum install wget
б) на Ubuntu / Debian:
apt-get install wget
После установки wget перейдем в каталог /tmp:
Открываем браузер и заходим на страницу загрузки коннекторов MariaDB и выбираем ODBC connector, а также нашу операционную систему, например:
* в данном случае мы загрузим коннектор для CentOS 8.
Ниже на этой же страницы мы увидим ссылку на скачивание нужного нам коннектора. Копируем данную ссылку:
С помощью wget и скопированной ссылки загружаем на сервер коннектор:
tar zxvf mariadb-connector-odbc-*.tar.gz
И копируем библиотеки в каталог /usr/lib64:
cp mariadb-connector-odbc-*-amd64/lib64/mariadb/lib* /usr/lib64/
После скачанный архив и распакованный каталог можно удалить:
rm -rf mariadb-connector-odbc-*
Установка и подготовка к работе СУБД
Для проверки настройки нам нужен сервер баз данных. Если его нет, то установим mariadb-server на тот же сервер, где и развернули ODBC.
а) для CentOS / Red Hat:
yum install mariadb-server
б) для Ubuntu / Debian:
apt-get install mariadb-server
После установки запускаем сервис и настраиваем его на автозапуск:
systemctl enable mariadb —now
Задаем пароль для суперпользователя:
mysqladmin -u root password
Заходим в консоль SQL:
Создаем новую базу данных:
> CREATE DATABASE my_db DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
* для наших тестов мы создали базу с названием my_db.
Дадим права на подключение и работу с созданной базой данных:
> GRANT ALL PRIVILEGES ON my_db.* TO ‘odbc_user’@’localhost’ IDENTIFIED BY ‘odbc_password’;
* данной командой мы разрешили доступ к базе my_db пользователю odbc_user, который будет подключаться с локального компьютера и паролем odbc_password.
Подключаемся к созданной базе данных:
Создаем простенькую таблицу:
> CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(512) NOT NULL,
`rights` varchar(64) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
* наша созданная таблица будет состоять из 3 столбцов — id, name и rights.
Добавим 3 строки в нашу таблицу:
> INSERT INTO users (`name`, `rights`) VALUES (‘Дмитрий’, ‘admin’), (‘Оля’, ‘superuser’), (‘Антон’ ,’operator’);
Готово. Теперь выходим из sql-оболочки:
Установка и настройка ODBC
Устанавливаем сам ODBC.
а) для CentOS / Red Hat:
yum install unixODBC
б) для Ubuntu / Debian:
apt-get install unixodbc odbcinst
Открываем конфигурационный файл:
Проверяем наличие следующей записи (если ее нет, добавляем):
.
[MariaDB]
Description = ODBC for MariaDB
Driver = /usr/lib/libmaodbc.so
Driver64 = /usr/lib64/libmaodbc.so
FileUsage = 1
.
* в данном примере описано подключение к СУБД с драйвером MariaDB и путем до файла с библиотекой (отдельно для 32- и 64-разрядной версии).
Добавляем DSN для подключения к нашему серверу и базе, которую создавали на предыдущем этапе:
[ODBC]
Driver = MariaDB
USER = odbc_user
PASSWORD = odbc_password
Server = 127.0.0.1
Database = my_db
Port = 3306
- ODBC — произвольное название для нашего подключения.
- Driver — драйвер, который мы будем использовать. Его мы описали в файле /etc/odbcinst.ini.
- USER — пользователь, под которым будем подключаться к базе. Используем данные для ранее созданной учетной записи в mariadb.
- PASSWORD — пароль для созданного ранее пользователя, под которым мы будем подключаться к базе.
- Server — сервер баз данных. В нашем примере локальный сервер.
- Database — имя созданной базы данных.
- Port — порт, на котором слушает сервер. 3306 используется по умолчанию для MariaDB.
Пробуем подключиться к базе с использованием ODBC:
* где ODBC — название для подключения, которое мы задали на предыдущем шаге.
Мы должны увидеть командную строку для ввода команд sql — пробуем получить данные из нашей таблицы users:
Источник