Bug 136290 - mysql-direct-connector no longer working in LO 6.4 or 7.0 with particular non-system default mysql server local installation
Summary: mysql-direct-connector no longer working in LO 6.4 or 7.0 with particular non...
Status: RESOLVED DUPLICATE of bug 134982
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
7.0.0.3 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL: https://docs.vultr.com/how-to-install...
Whiteboard: tutorial on installing MySQL on Ubunt...
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-30 14:51 UTC by Duns
Modified: 2024-11-29 21:32 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Duns 2020-08-30 14:51:55 UTC
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
Comment 1 Robert Großkopf 2020-08-30 15:55:03 UTC
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.
Comment 2 Duns 2020-08-30 16:08:37 UTC
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
Comment 3 Alex Thurgood 2020-08-31 11:36:25 UTC
(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
Comment 4 Alex Thurgood 2020-09-01 08:12:24 UTC

*** This bug has been marked as a duplicate of bug 134982 ***
Comment 5 Mysql Gyuder 2024-11-29 21:32:22 UTC
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!