Page 1 of 1

Connecting to remote MySQL Database

Posted: Wed May 05, 2021 6:38 pm
by w1177273@gmail.com
I am trying to connect to a remote MySQL database which I can access using PHP:

$con = new mysqli('localhost',"myuserid","mypassword","mydatabasename");

I assume I have to set up a connexion in Database. I then tried:
Connect to an existing database: MySQL
Next How do I want to connect? Tried ODBC.
Then it asked for the name of ODBC Source which I do not know.

Is there a simple guide to connecting to remove MySQL Databases?

Re: Connecting to remote MySQL Database

Posted: Wed May 05, 2021 7:12 pm
by Villeroy
Install https://libreoffice.org/
File>New>Database...
Connect to existing database
Type: MySQL
[X] Connect directly (using the driver that is shipped with LibreOffice)
Enter database name, host, port, user name and check "Password required".
Click [Test Connection] and enter the password.
Register the database document if you need data in office documents (does not harm anyway).
Save the database document.

Re: Connecting to remote MySQL Database

Posted: Wed May 05, 2021 11:24 pm
by w1177273@gmail.com
Thank you . Libre Office seems to have simpler interface than Open Office as it has a direct connexion.
Unfortunately I get an error
Lost connection to MySQL server at 'handshake: reading initial communication packet', system error: 34
So it looks like I am closer. Do you have any suggestion?

When I first connected, it would not accept the URL or IP. It needed localhost. But to access remotely, I will need one of these. (They both give the same error.)

Re: Connecting to remote MySQL Database

Posted: Wed May 05, 2021 11:57 pm
by Villeroy
Install Java and use JDBC with a JDBC driver for MySQL
Tools>Options>Advanced>Class Path... and point to mysql-connector-java.jar (that's the driver's file name on my system).

Restart office.

Create a database of type MySQL, then choose JDBC and when prompted for the driver class: com.mysql.jdbc.Driver
You can also create a database of type JDBC with a connection URL jdbc:mysql://localhost:3306/TESTDB and the same driver class.
I don't know how to handle ODBC on Windows. That would be the 4th variant how to connect a LibreOffice Base document to MySQL.