I was following the instructions for registering a driver and data source given here: "Installing Connector/ODBC from a Binary Tarball Distribution"
After realizing I had to use sudo when running myodbc-installer, I could successfully get the driver I installed to show as registered, with:
shell> myodbc-installer -d -l
MySQL ODBC 8.0 Driver
When you run myodbc-installer with no arguments, it lists the command line switches and also tells you how to register a data source. The example it gives is:
Add a new system data source name for Unicode driver
shell> myodbc-installer -s -a -c2 -n "test" \
-t "DRIVER=MySQL ODBC 8.0 Unicode Driver;SERVER=localhost;DATABASE=test;UID=myid;PWD=mypwd"
That didn't exactly match the name (it's MySQL ODBC 8.0 Driver, not MySQL ODBC 8.0 Unicode Driver... the ASCII driver is merely MySQL ODBC 8.0 😒)
But using the appropriate driver name, I managed to get the installer to successfully register a data source, which could be listed back:
shell> myodbc-installer -s -l
test - MySQL ODBC 8.0 Driver
But the program I tried to use this DSN with wasn't working. So I thought I would look for some simpler case to try. The iodbctest program seemed like a good candidate, as it has a function where you hit ? and it lists the data sources. But I don't get anything...
shell> iodbctest
iODBC Demonstration program
This program shows an interactive SQL processor
Driver Manager: 03.52.0812.0326
Enter ODBC connect string (? shows list): ?
DSN | Driver
------------------------------------------------------------------------------
Enter ODBC connect string (? shows list):
Since sudo helped with the installation process, I thought I'd try sudo iodbctest, but that did not help.
So I thought I would look for some simpler case to try. The iodbctest program seemed like a good candidate, as it has a function where you hit ? and it lists the data sources.
Don't mix installs of iodbc and unixodbc. iodbc isn't an abstract set of tools and tests for ODBC, it is a completely independent implementation of ODBC from unixodbc.
In my case, I first installed unixodbc. So that's what myodbc-installer asked to register the drivers and data sources, via shared library functions. But it wrote the .INI files in a way that doesn't match what iodbc would have written.
Case in point: the iodbctest client appears to not be dynamically linked to use whatever ODBC provider is on your system. It is statically linked to iodbc routines that look explicitly in the odbc.ini file for an [ODBC Data Sources] section. This index does not appear to be made automatically by the unixodbc registration process.
(Note: This may be a bug in either unixodbc or mysql-installer's usage of it, as the documentation says "An [ODBC Data Sources] section is maintained in each odbc.ini and may or may not be used by the odbcinst library.")
Interestingly, while the mysql-installer tells you how to use it to register a data source, a different suggestion on the MySQL website tells you to edit the INI file by hand. This contradicts what unixodbc says, which is "NOTE: odbc.ini and odbcinst.ini are considered to be ODBC System Information. All access (read or write) to this System Information should occur via the Driver Manager or the ODBCINST share library. Do not access these INI files directly!" (emphasis theirs)
Beyond the issue of not being able to get the index, even if you do connect to a data source on Linux, iODBC uses wchar_t and not SQLWCHAR. So with a unicode driver, you'll get a bunch of gibberish back from your queries.
Related
I'm trying to import data from a MySQL Database to an Excel 365 (32 bit) Workbook.
This is a DB I can link to without any issues :
This is the DB I can't link to :
I've downloaded the following connector :
MySQL Connector Net 6.10.6
I suspect that this is not the correct connector for the second DB.
The error is this :
[MySQL: Unable to connect to any of the specified MySQL hosts.]
Could someone point me to the beginning of a solution ?
I've also tried to connect via VBA but I also get an error which must be due to the same causes as above.
If the database server and the database client (Excel) are running on different machines then they cannot communicate via UNIX filesystem sockets.
If you specify localhost as the target host in a libmysql client, then the client will try to connect via the (Unix) filesystem socket.
On the other hand, if you instead specify 127.0.0.1, it will use a TCP socket.
More Information:
Stack Overflow : How to connect to database when server is in Unix socket? (MySQL/PHP)
Wikipedia: Localhost
Wikipedia : Unix domain socket
Wikipedia : TCP Socket definition
MySQL.com : Configuring a Connector/ODBC DSN on Windows with the ODBC Data Source Administrator GUI
EDIT:
In response to your comment, the target host would be specified in the location specified on this page, or it can also be installed via command line with these steps.
Also you might find this helpful:
mysql.com : Using Connector/ODBC with Microsoft Word or Excel
mysql.com : Using Connector/ODBC with Microsoft Access
Setting up a MySQL ODBC DSN on Windows 7 64-bit:
I have a faint recollection of the last time I setup an ODBC DSN to MySQL.
It was a while ago so I might be mistaken on the details but I'm pretty sure that the only was I was able to get it working on a 64-bit system (possibly because the server was 32-bit?) was to install both the 32-bit and 64-bit drivers (from here) into separate folders, rebooting between each install. As I recall, it took a dozen install/uninstalls before I got it right.
Once it was properly installed, I had to administer it with Window's 32-bit version of ODBC Administrator.
There's 2 versions of ODBC Administrator (aka 'Data Sources'), confusingly:
My 64-bit version is located at : c:\windows\system32\odbcad32.exe
My 32-bit version is located at : c:\windows\SysWOW64\odbcad32.exe
Note that much of this is from memory and unverified!
I have this text file sitting in my "mySQL Notes" folder, so I gather I ended up using the command line to get it installed:
myodbc-installer -s -a -c1 -n " mysqlDSN " -t "DRIVER=MySQL ODBC 5.3 Unicode Driver;SERVER= (server name) ;DATABASE= (database name) ;UID= (user name) ;PWD= (password) "
In my case I was setting up connection to a web host server, so I referred to my CPanel for the server / database / uid values.
...and as I recall, I had to run it from the location of the 32-but version of the myodbc-installer. Also, you'll have an ODBC.INI text file somewhere showing the configuration.
More detail under the plethora of information here:
mysql.com : MySQL Connector/ODBC Developer Guide
I am having problems accessing my MySQL database from R on mac (Mac OS X 10.11.2). The following code:
library("RODBC")
mycom <- odbcConnect("wsn_mysql_5", uid="root", pwd="*****")
Gives this error:
1: In RODBC::odbcDriverConnect("DSN=wsn_mysql_5;UID=root;PWD=****") :
[RODBC] ERROR: state 00000, code 15509574, message
[iODBC][DriverManager]dlopen(/usr/local/lib/libmyodbc5a.so,
6): no suitable image found. Did find:
/usr/local/lib/libmyodbc5a.so: mach-o, but wrong architecture
2: In RODBC::odbcDriverConnect("DSN=wsn_mysql_5;UID=root;PWD=****") :
[RODBC] ERROR: state IM003, code 15509574, message
[iODBC][Driver Manager]Specified driver could not be loaded
What I have tried so far:
I installed iODBC driver manager 3.52.12.
I installed MySQL connector odbc-5.3.6-osx10.11-x86-64bit and created a DSN (server=localhost, user=root, password=*****,database=wsn_db).
I was getting this error when testing it in iODBC Administrator:
[iODBC][Driver manager]dlopen(/usr/local/lib/libmyodbc5w.so, 6): no suitable image found.
Did find: /usr/local/lib/libmyodbc5w.so: mach -o, but wrong architecture.
How to add ODBC to MAMP on OSX led me to think that is was a 32-bit vs 64-bit problem.
So I installed MySQL connector odbc-5.2.7-osx10.7-x86-32bit which is the most recent 32-bit version I found. When I test this with iODBC Administrator, it seems to work, but I get the error mentioned at the beginning when I try the code in R.
The FAQ of iODBC says the following regarding this type of error:
[iODBC] [Driver Manager]Specified driver could not be loaded
There are a few reasons why this could occur, and thinking through the architecture helps. Your application has loaded libiodbc successfully, and it has found an odbc.ini file (or equivalent through the ODBCINI environment variable), and it has found a DSN within that odbc.ini that matches the name requested in your connection.
However, the driver manager has had problems loading the library specified in the `Driver=' line of that DSN definition. Either it doesn't exist, or its permissions are insufficient to allow your application to load it (it must be readable and executable, and the directories leading down to it must be executable), or maybe the file is not a dynamic library - it could be a static library (a *.a file except on AIX) or is otherwise corrupted. These are all things to check, or you may be best off reinstalling the driver if all the permissions check out.
So I checked the permission, but they were correct.
I also reinstalled the driver, but it didn't change anything.
After reading this, I checked odbc.ini and obdcinst.ini.
I changed odbc.ini to:
[ODBC Data Sources]
wsn_mysql_7 = wsn_mysql_7
[ODBC]
TraceLibrary=
[wsn_mysql_7]
Driver = /usr/local/lib/libmyodbc5w.so
DATABASE = wsn_db
DESCRIPTION = DSN for wsn_db in R
SERVER = localhost
UID = root
PASSWORD = *****
and odbcinst.ini to
[ODBC Drivers]
MySQL ODBC 5.2 ANSI Driver=Installed
MySQL ODBC 5.2 Unicode Driver=Installed
[ODBC Connection Pooling]
PerfMon=0
Retry Wait=
[MySQL ODBC 5.2 ANSI Driver]
Driver = /usr/local/lib/libmyodbc5a.so
Description = mySQL driver
Threading = 0
[MySQL ODBC 5.2 Unicode Driver]
Driver = /usr/local/lib/libmyodbc5w.so
Description = mySQL driver
Threading = 0
But it didn't seem to change anything.
I also tried an alternative RODBC code based on this question.
mycom <- odbcDriverConnect("Provider=MSDASQL;Driver={MySQL ODBC 5.2 UNICODE Driver};
Server=localhost;database=wsn_db;Uid=root;Pwd=*****;Option=3")
I am not sure what to do next? Even a completely different way to access the mySQL data in R would help.
I finally manage to have a working configuration by using unixODBC and using a 64-bit ANSI connector. If you are trying to connect to a MySQL database with RODBC I recommend:
To follow this tutorial to install unixODBC and RODBC
Install the latest MySQL ODBC connector. I installed mysql-connector-odbc-5.3.6-osx10.11-x86-64bit. I had to install from tar since the installer didn't work. The instructions are here.
I used ODBC Administrator to configure the DSN, but I guess the instruction from [Hiltmon's tutorial] might work as well.
I first used the Unicode driver, but got the following error:
Warning messages:
1: In RODBC::odbcDriverConnect("DSN=wsn_db_dsn;UID=root;PWD=****") :
[RODBC] ERROR: state H, code 0, message [unixODBC][
2: In RODBC::odbcDriverConnect("DSN=wsn_db_dsn;UID=root;PWD=****") :
ODBC connection failed
I corrected this by selecting the ANSI driver as suggested in RODBC error - ODBC connection failed - can't connect to MySQL with my mac (mavericks).
I hope this can save time to someone.
I'm struggling to get Squirrel SQL to connect to MS Access database (just a normal one, no password):
I create an Alias and use Driver: JBDC ODBC bridge (There is a tick in front of this driver)
I don't know what to put in URL
-------- I use: Path to database file ~~> Unsuccessful
-------- I use: jdbc:odbc:Path to database file ~~> Unsuccessful
I'm running it on windows 7.
I guest this should be a simple straight forward process, but please advise me how to get it working.
Now that the JDBC-ODBC Bridge has been removed from Java 8 the previous answer to this question will become less relevant over time. The following method uses the UCanAccess JDBC driver so it will work with Java 8 and it will also work on non-Windows platforms.
First, make sure that you are using UCanAccess version 3.0.5 or later. Download the latest version of the UCanAccess driver (bin.zip file) and unzip it to a convenient location. For this example I unzipped it to
/home/gord/Downloads/JDBC/UCanAccess
Note: When unzipping the distribution file be sure to specify "Keep directory structure" (or similar, depending on your unzip tool) so the folder structure appears as in the screenshot above.
Creating a Squirrel SQL "Driver" entry (one-time setup)
In Squirrel SQL, create a new "Driver" entry for UCanAccess
and specify the location of loader/ucanload.jar on the "Extra Class Path" pane
Note: Remember to enter net.ucanaccess.jdbc.UcanloadDriver as the "Class Name" (see above).
Creating a database "Alias" (one for each database)
To open a specific database, create a Squirrel SQL "Alias" entry, replacing the <path_to_database_file> placeholder with the actual path to the file
or, in Windows
Important: Make sure that the connection URL ends with ;showSchema=true.
I found the solution. Put below string in URL:
(Assuming that path to your database file is D:\DBs\DatabaseFile.mdb)
jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=D:\DBs\DatabaseFile.mdb
I am getting the following error when I try to configure MySQL instance, could any one help out to resolve this error.
I am using Windows XP SP2.
If you reinstall or upgrade MySQL without first stopping and removing the existing MySQL service and install MySQL using the MySQL Configuration Wizard, you may see this error:
Error: Cannot create Windows service for MySql. Error: 0
This occurs when the Configuration Wizard tries to install the service and finds an existing service with the same name.
One solution to this problem is to choose a service name other than mysql when using the configuration wizard. This enables the new service to be installed correctly, but leaves the outdated service in place. Although this is harmless, it is best to remove old services that are no longer in use.
To permanently remove the old mysql service, execute the following command as a user with administrative privileges, on the command-line:
shell> sc delete mysql
[SC] DeleteService SUCCESS
If the sc utility is not available for your version of Windows, download the delsrv utility from http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/delsrv-o.asp and use the delsrv mysql syntax.
-- http://dev.mysql.com/doc/refman/5.0/en/windows-troubleshooting.html
Usually when the service doesn't manage to start, there will be more detailed information about what went wrong somewhere:
In mySQL's your_hostname_here.err file
In the system's error log (In english-language Windows, it's called event log I think)
you need to look there for the reason.
I have Oracle SQL Developer already installed and am able to connect to and query Oracle databases.
Using Help -> Check for Updates I was able to install the Oracle MySQL Browser extension but there are no connection options for MySQL databases.
Under Tools > Preferences > Databases there is a third party JDBC driver path that must be setup. Once the driver path is setup a separate 'MySQL' tab should appear on the New Connections dialog.
Note: This is the same jdbc connector that is available as a JAR download from the MySQL website.
In fact you should do both :
Add driver
Download driver https://maven.atlassian.com/content/groups/public/mysql/mysql-connector-java/5.1.29/
To add this driver :
In Oracle SQL Developper > Tools > Preferences... > Database > Third Party JDBC Drivers > Add Entry...
Select previously downloaded mysql connector jar file.
Add Oracle SQL developper connector
In Oracle SQL Developper > Help > Check for updates > Next
Check All > Next
Filter on "mysql"
Check All > Finish
Next time you will add a connection, MySQL new tab is available !
Here's another extremely detailed walkthrough that also shows you the entire process, including what values to put in the connection dialogue after the JDBC driver is installed: http://rpbouman.blogspot.com/2007/01/oracle-sql-developer-11-supports-mysql.html
My experience with windows client and linux/mysql server:
When sqldev is used in a windows client and mysql is installed in a linux server meaning, sqldev network access to mysql.
Assuming mysql is already up and running and the databases to be accessed are up and functional:
• Ensure the version of sqldev (32 or 64). If 64 and to avoid dealing with path access copy a valid 64 version of msvcr100.dll into directory ~\sqldeveloper\jdev\bin.
a. Open the file msvcr100.dll in notepad and search for first occurrence of “PE “
i. “PE d” it is 64.
ii. “PE L” it is 32.
b. Note: if sqldev is 64 and msvcr100.dll is 32, the application gets stuck at startup.
• For sqldev to work with mysql there is need of the JDBC jar driver. Download it from mysql site.
a. Driver name = mysql-connector-java-x.x.xx
b. Copy it into someplace related to your sqldeveloper directory.
c. Set it up in menu sqldev Tools/Preferences/Database/Third Party JDBC Driver (add entry)
• In Linux/mysql server change file /etc/mysql/mysql.conf.d/mysqld.cnf
look for
bind-address = 127.0.0.1 (this linux localhost)
and change to
bind-address = xxx.xxx.xxx.xxx (this linux server real IP or machine name if DNS is up)
• Enter to linux mysql and grant needed access for example
# mysql –u root -p
GRANT ALL ON . to root#'yourWindowsClientComputerName' IDENTIFIED BY 'mysqlPasswd';
flush privileges;
restart mysql - sudo /etc/init.d/mysql restart
• Start sqldev and create a new connection
a. user = root
b. pass = (your mysql pass)
c. Choose MySql tab
i. Hostname = the linux IP hostname
ii. Port = 3306 (default for mysql)
iii. Choose Database = (from pull down the mysql database you want to use)
iv. save and connect
That is all I had to do in my case.
Thank you,
Ale
Although #BrianHart 's answer is correct, if you are connecting from a remote host, you'll also need to allow remote hosts to connect to the MySQL/MariaDB database.
My article describes the full instructions to connect to a MySQL/MariaDB database in Oracle SQL Developer:
https://alvinbunk.wordpress.com/2017/06/29/using-oracle-sql-developer-to-connect-to-mysqlmariadb-databases/
You may find the following relevant as well:
Oracle SQL Developer connection to Microsoft SQL Server
In my case I had to place the ntlmauth.dll in the sql-developer application directory itself (i.e. sql-developer\jdk\jre\bin). Why this location over the system jre/bin I have no idea. But it worked.