Did you mean to connect to: mysql://localhost:3306?
Port 3306 is for database connections, not web browsers. Use your MySQL client or application to connect.
sudo systemctl status mysql
(Linux)brew services list | grep mysql
(Mac)net start mysql
(Windows)
mysql -u root -p
mysql -h localhost -P 3306 -u username -p
lsof -i :3306
(Mac/Linux)netstat -ano | findstr :3306
(Windows)
sudo systemctl start mysql
(Linux)brew services start mysql
(Mac)net start mysql
(Windows)
Port 3306 is the default port for:
This Windows error indicates MySQL service is not running:
net start mysql
mysql --version
Authentication error when connecting to MySQL:
sudo mysql -u root -p ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword'; FLUSH PRIVILEGES;
mysql -u root --auth-socket
SELECT user,host FROM mysql.user;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost'; FLUSH PRIVILEGES;
Common on Linux/Mac when MySQL socket file is missing:
sudo systemctl status mysql
sudo find / -name "*.sock" 2>/dev/null | grep mysql
sudo systemctl start mysql
mysql -h 127.0.0.1 -P 3306 -u root -p
Another process is using MySQL's port:
lsof -i :3306
or netstat -tulpn | grep 3306
sudo systemctl stop mysql
sudo kill -9 PID
[mysqld] port = 3307
sudo systemctl start mysql
MySQL is blocking connections from your host:
GRANT ALL PRIVILEGES ON *.* TO 'username'@'your_ip' IDENTIFIED BY 'password'; FLUSH PRIVILEGES;
[mysqld] bind-address = 0.0.0.0
SELECT user,host FROM mysql.user;