Look, I get it. You're knee-deep in MW-PANEL, trying to import a damn SQL file into MariaDB, and BAM—ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)
. Suddenly, you're questioning your life choices. Relax. I've been there, smashed three keyboards, and lived to tell the fix. Here's the no-BS guide for real humans.
⚠️ Why This Error Makes You Want to Throw Servers Out the Window:
- MW-PANEL uses
/www/server/mariadb/mysql.sock
— NOT the default/run/mysqld/mysqld.sock
- MariaDB service might be dead (thanks, universe)
- Permissions? What permissions? (Spoiler: It's always permissions)
The 5-Second Fix (Drop the Mic)
/www/server/mariadb/bin/mysql --socket=/www/server/mariadb/mysql.sock -u your_user -p your_db < /tmp/your_db.sql
Yes, that --socket
flag is the holy grail. Works 90% of the time. Now, for the other 10%...
Nuclear Solutions When Sh*t Still Hits the Fan
1. Resurrect MariaDB (Is It Even Alive?)
sudo systemctl status mariadb # If 'dead', pour coffee on it: sudo systemctl restart mariadb sudo systemctl enable mariadb # Make it survive reboots
2. Create a Socket Symlink (The "Fake It Till You Make It" Approach)
sudo mkdir -p /run/mysqld sudo ln -s /www/server/mariadb/mysql.sock /run/mysqld/mysqld.sock
3. Force-Feed the Correct Config
Edit /www/server/mariadb/my.cnf
and shove this in:
[client] socket = /www/server/mariadb/mysql.sock [mysqld] socket = /www/server/mariadb/mysql.sock
Then sudo systemctl restart mariadb
. Don't forget this. Seriously.
4. Nuke Permission Problems
sudo chown -R mysql:mysql /www/server/mariadb/data sudo chmod 755 /www/server/mariadb/mysql.sock
5. When All Else Fails: TCP/IP Override
# Connect via network instead of socket /www/server/mariadb/bin/mysql -h 127.0.0.1 -P 3306 -u user -p db < file.sql
MW-PANEL Specific Pro Moves
🔧 Port Configuration
Changed the port? Update MW-PANEL's config:
define('DB_HOST', 'localhost:3307'); // In wp-config.php
Find ports via MW-PANEL menu → MySQL → "Ports Used" :cite[2]
💾 Critical Paths
- Error logs:
/www/server/mariadb/data/error.log
- Config file:
/www/server/mariadb/my.cnf
- Data dir:
/www/server/mariadb/data
Importing Massive SQL Files? Don't Time Out
screen -S mega_import # Create persistent session /www/server/mariadb/bin/mysql --socket=... -u user -p db < huge_file.sql Ctrl+A+D # Detach (runs in background) screen -r mega_import # Reattach later
Performance Tuning for Cheap Servers
Got only 512MB RAM? Paste this in my.cnf
under [mysqld]
:
innodb_buffer_pool_size = 96M key_buffer_size = 4M max_connections = 50 thread_cache_size = 4 innodb_flush_log_at_trx_commit = 2 # Faster writes, slight risk
Restart. Boom. 3x speed boost :cite[4].
Remote Access Without Public IP? Yes.
Use cpolar to tunnel MariaDB securely:
- Install cpolar, create TCP tunnel to localhost:3306
- Grab public URL like
3.tcp.cpolar.top:11241
- Connect remotely via Navicat/HeidiSQL :cite[7]:cite[10]
🚀 Pro Tips to Avoid Future Therapy Bills:
- ALWAYS specify
--socket
in MW-PANEL environments - Test MariaDB status before imports:
systemctl status mariadb
- Logs are your best friend:
tail -f /www/server/mariadb/data/error.log
- Port conflict? Change MariaDB's port in
my.cnf
→port=3307
Real Talk: If you skip socket configs in MW-PANEL, you're just begging for ERROR 2002. Save yourself—bookmark this guide now.
Comments NOTHING