Description: I have KDE Neon with mysql-connectr provided in Synaptic, and after upgrading to 20.04 (Kubuntu packages) LibreOffice 6.4 (and 7.0) can't directly connect with mysql. I receive this error message: SQL Status: HY000 Error code: 2003 Can't connect to MySQL server on 'localhost' (111) /build/libreoffice-ron9it/libreoffice-7.0.0~rc3/connectivity/source/drivers/mysqlc/mysqlc_general.cxx:119 I have lampp in /opt In 6.0 all it's ok. Steps to Reproduce: 1. In LibreBase try to establish a direct connection with mysql 2. give user and pass, and socket location 3. you receive the erroir massage reporte above: "Error code: 2003 Can't connect to MySQL server on 'localhost' (111) Actual Results: No direct connection with mysql Expected Results: direct connection with mysql Reproducible: Always User Profile Reset: No Additional Info: Version: 7.0.1.2 Build ID: 00(Build:2) CPU threads: 2; OS: Linux 5.4; UI render: default; VCL: gtk3 Locale: it-IT (en_US.UTF-8); UI: en-US Ubuntu package version: 1:7.0.1_rc2-0ubuntu0.20.04.1 Calc: threaded
Isn't this a duplicate of bug134982 ? No problem here to connect to MariaDB with direct connection and the original packages from LO, versions LO 7.0.0.3 or LO 6.3.6.1 on OpenSUSE 15.1 64bit rpm Linux.
Maybe is the same problem, yes. But there someone says to do a symlink from the lampp socket (in /opt) to "the place where LO expects to find it". But can you kindly tell me where is this place? Thank you
(In reply to Duns from comment #2) > Maybe is the same problem, yes. > But there someone says to do a symlink from the lampp socket (in /opt) to > "the place where LO expects to find it". > But can you kindly tell me where is this place? > Thank you It depends on your Linux distrib and therefore has nothing to do with LO, per se. I would suggest looking up where Ubuntu 20.04 installs the Unix socket connection file when you install mysql server via the distrib provided package... at a guess, probably somewhere in /var/run/, cf. for example, here: https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04-fr
*** This bug has been marked as a duplicate of bug 134982 ***
I faced a similar issue when setting up MySQL on Ubuntu 20.04 and integrating it with PHP. The problem occurred due to MySQL's default `auth_socket` plugin for authentication, which often causes connection issues when using PHP. Here's how I resolved it, step-by-step: --- ### Step 1: Verify MySQL Installation Ensure that MySQL is installed and running on your Ubuntu system. You can confirm by checking the service status: ```bash sudo systemctl status mysql ``` If MySQL isn’t installed, follow this comprehensive [tutorial on installing MySQL on Ubuntu 20.04](https://docs.vultr.com/how-to-install-mysql-on-ubuntu-24-04). --- ### Step 2: Identify the Unix Socket File Ubuntu places the MySQL socket file in `/var/run/mysqld/mysqld.sock` by default. You can confirm the location in the MySQL configuration file: ```bash sudo cat /etc/mysql/mysql.conf.d/mysqld.cnf ``` Look for the line: ```text socket = /var/run/mysqld/mysqld.sock ``` --- ### Step 3: Adjust Root Authentication MySQL on Ubuntu 20.04 often uses the `auth_socket` plugin for the root user. This means you can connect without a password from the terminal but not from PHP. To fix this: 1. Log into MySQL: ```bash sudo mysql ``` 2. Change the authentication method for the root user: ```sql ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password_here'; FLUSH PRIVILEGES; ``` 3. Test the new credentials by running: ```bash mysql -u root -p ``` Enter the password you just set. --- ### Step 4: Test PHP Connection to MySQL Create a PHP file (`db_test.php`) to test the connection: ```php <?php $servername = "localhost"; $username = "root"; $password = "your_password_here"; $dbname = "test_db"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } echo "Connected successfully"; ?> ``` Place this file in your Apache web directory (usually `/var/www/html`) and open it in your browser. If everything is set up correctly, it should display: ```text Connected successfully ``` --- ### Step 5: Create a Dedicated MySQL User (Optional) For better security, create a dedicated user for your application: ```sql CREATE USER 'app_user'@'localhost' IDENTIFIED BY 'secure_password'; GRANT ALL PRIVILEGES ON test_db.* TO 'app_user'@'localhost'; FLUSH PRIVILEGES; ``` Update your PHP script to use this new user's credentials. --- ### Additional Resources I found this tutorial on MySQL setup ) very helpful for understanding MySQL installation and configuration on Ubuntu. It also provides insights into handling authentication methods and optimizing your setup. By following these steps, I was able to resolve the connection issue and properly integrate MySQL with PHP. Hopefully, this helps others facing the same challenge!