Linux Endless OS 3下XAMPP phpMyAdmin出现#2002访问拒绝错误
Hey there, let's get that frustrating phpMyAdmin error sorted out. The "2002 - No such file or directory" message almost always boils down to two issues: either MySQL isn't running, or phpMyAdmin can't locate the MySQL socket file. Here's how to fix it step by step:
1. Check if MySQL is Running in XAMPP
First things first—confirm the MySQL service is active:
- Open your XAMPP Control Panel (you’ll find it in your Endless OS app launcher). Look for the MySQL module; if its status isn’t Running, click the Start button.
- If the GUI fails to start MySQL, try the command line:
- Open a terminal and navigate to XAMPP’s bin directory:
cd /opt/lampp/bin/ - Start MySQL manually:
sudo ./mysqld_safe &
- Open a terminal and navigate to XAMPP’s bin directory:
2. Fix the MySQL Socket Path Mismatch
phpMyAdmin might be looking for the MySQL socket in the wrong location. Let’s correct that:
- First, find where XAMPP’s MySQL stores its socket file. Run this command in terminal:
You’ll get a path like/opt/lampp/bin/mysql_config --socket/opt/lampp/var/mysql/mysql.sock—copy this string. - Next, edit phpMyAdmin’s config file with sudo privileges:
sudo nano /opt/lampp/phpmyadmin/config.inc.php - Look for the line that says:
Replace the empty string with the socket path you copied earlier, so it looks like:$cfg['Servers'][$i]['socket'] = '';$cfg['Servers'][$i]['socket'] = '/opt/lampp/var/mysql/mysql.sock'; - Save and exit the editor: press
Ctrl+O, hit Enter, thenCtrl+X.
3. Fix Permissions or Corrupted MySQL Files
If MySQL refuses to start, permission issues or corrupted database files might be to blame:
- Set the correct ownership for MySQL’s data directory:
sudo chown -R mysql:mysql /opt/lampp/var/mysql/ - Try repairing all MySQL databases to fix potential corruption:
(XAMPP’s default root password is blank—just press Enter when asked for a password.)sudo /opt/lampp/bin/mysqlcheck --all-databases -u root -p
4. Restart XAMPP
After making any changes, restart XAMPP to apply them:
- In the XAMPP Control Panel, click Stop for all running services, then click Start again.
- Or use the command line:
sudo /opt/lampp/lampp restart
Once you’ve completed these steps, try accessing http://localhost/phpmyadmin again—it should load without the 2002 error.
内容的提问来源于stack exchange,提问作者anand kumar

