“sqladmin 连接失败”在 Ubuntu 上常见原因很多,需要看你具体是哪种 sqladmin:
下面按最常见场景给你一套排查思路。
不同数据库原因完全不同:
systemctl status mysql
# 或
systemctl status mariadb
启动:
sudo systemctl start mysql
查看:
sudo netstat -tlnp | grep 3306
如果看到:
127.0.0.1:3306
说明只能本机连
修改:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
改为:
bind-address = 0.0.0.0
重启:
sudo systemctl restart mysql
例如:
SELECT host FROM mysql.user WHERE user='sqladmin';
如果 host 是 localhost,远程连不了。
解决:
CREATE USER 'sqladmin'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'sqladmin'@'%';
FLUSH PRIVILEGES;
sudo ufw status
允许:
sudo ufw allow 3306
systemctl status postgresql
sudo nano /etc/postgresql/*/main/postgresql.conf
确认:
listen_addresses = '*'
sudo nano /etc/postgresql/*/main/pg_hba.conf
加:
host all all 0.0.0.0/0 md5
重启:
sudo systemctl restart postgresql
systemctl status mssql-server
sudo netstat -tlnp | grep 1433
sudo /opt/mssql/bin/mssql-conf setup
常见错误:
mysqli extension missingCannot log in to the MySQL server检查:
sudo apt install php-mysqli
sudo systemctl restart apache2
请告诉我:
我可以直接帮你精准判断 ✅