Import MySQL data to Excel 365

风格不统一 提交于 2020-07-08 03:02:59

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/49129412/import-mysql-data-to-excel-365

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!