WLAMP Installation

WSL2 brought about a new thing. Windows LAMP Stack.
As an IT in a company we often times are forced to use what is available and are not allowed to turn a windows box into a linux box. So enters Windows Subsystem for Linux.
For awhile now I had no issues installing LAMP stack on WSL's Ubuntu 16.04 down to Ubuntu 20.04 and It's a matter of migrating data and upgrading my company's site. Unfortunately on Ubuntu 22.04 I get stuck with installing phpmyadmin which is what my company wants. It always failed with error HY000/2002 and permission denied.

Here's the Installation part that leads up to the picture above:
sudo apt update && sudo apt -y upgrade
sudo apt install apache2 php php-dom unzip mysql-server
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NEWPASSWORD';
flush privileges;
quit;
sudo service apache2 start
sudo service mysql start
sudo apt install phpmyadmin
It took some time for me to find out that the actual permission that is being denied is not the permission/privelege of the mysql user but rather the access to the mysql socket file commonly located at
/var/run/mysqld/mysqld.lock
I had to edit config.inc.php and configure the socket to use the correct socket file.

if (check_file_access('/var/run/mysqld/mysqld.sock'))
$cfg['Servers'][$i]['socket'] = '/var/run/mysqld/mysqld.sock';
else
die("Unable to access socket file");
Which results to this...

So I checked the folder permission and this is the result...

On checking my older Ubuntu installs The permission should be
drwxr-xr-x 2 mysql root 120 Jul 6 08:030 mysqld
So chmod +rx is the key
sudo chmod +rx /var/run/mysqld
Now phpmyadmin should work and it does now.


Not sure if the socket file permissions is a bug or an intended security measure but I am sure that adding read and execute permissions to it should not be a problem. A friend of mine always says that the most secure system is a system that is turned off, disconnected, placed inside an airtight chest, then placed inside a watertight chest, sealed, wrapped in chains with padlocks, and thrown to the ocean floor.