Faq/Base/021
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
How can I connect to a MySQL server under Linux?
For an ODBC connection to work under Linux (using unixODBC) a file to list the installed database drivers is required (in general the section name is that of the database, but it is not required).
Put the file odbcinst.ini in the directory /etc :
[MySQL] Description = MySQL driver Driver = /usr/local/lib/libmyodbc.so Setup = /usr/lib/libodbcmyS.so FileUsage = 1
and a file listing the database connection(s).
The first section defines the driver to use for a data source (database).
There are as many sections as there are data sources. This seems to create unnecessary duplication of driver definitions, but it is not clear why).
Put the file .odbc.ini in the user's home directory :
[ODBC Data Sources] TestMySQL = MySQL [TestMySQL] Description = Test TJ Driver = MySQL DSN = TestMySQL Trace = Off TraceFile = <trace filename> SERVER = @IP or name PORT = 3306 DATABASE = test USER = user MySQL Password = corresponding password
In this case the command will be : isql -v TestMySQL .
Start LibreOffice, select "View > Data sources" from the menu or press F4. The database dialogue will open below the icon bar.
Right click at the left and choose "Manage data sources".
In the window that opens click on "New database", enter it's name, choose ODBC from the list of database types, then click on the ellipsis (...) at the left.
In the window that opens choose your database (the database names that appear are those that have been defined in the .odbc.ini file in your home directory). Choose the one you require.
Click on the next tab (ODBC), enter the identifier, click the "password required" checkbox if necessary, then "OK".