Can’t install mysql-server on WSL2

  Kiến thức lập trình

I’m currently trying to connect a php application on WSL2 with a database initialized on my windows using xampp and TablePlus. I get an error that looks like this: [500]: GET / - Uncaught PDOException: SQLSTATE[HY000] [2002] Connection refused in ~/path/index.php:9 Stack trace: #0 ~/path/index.php(9): PDO->__construct() #1 {main} thrown in ~/path/index.php on line 9

When I looked upon StackOverflow, the solution was to change the localhost to, but even this couldn’t resolve the error. Then, another solution found was to initialize the mysql on WSL2. But when I try to install mysql-server, I get this error:

`$ sudo apt install mysql-server
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
libevent-pthreads-2.1-7 : Depends: libevent-core-2.1-7 (= 2.1.11-stable-1) but 2.1.12-stable-1build3 is to be installed
E: Unable to correct problems, you have held broken packages.`

I’ve already tried to update and upgrade with sudo apt upgrade && update, also tried downgrade with sudo aptitude update && sudo aptitude install build-essential, but even this couldn’t resolve it.