By default I am being connected to port 3309.I need to connect to port 3307.How do I do that?
How To Connect to MySQL Server on a Different Port? If your MySQL server is listening on port number different than 3306, you need to specify "--port=portNumber" option to any client program that needs to connect to the server.
To do this, create an option file for each server and tell the server the file name with a --defaults-file option when you run it. Suppose that you want to run one instance of mysqld on port 3307 with a data directory of C:\mydata1 , and another instance on port 3308 with a data directory of C:\mydata2 .
Client - Server Connection Ports Port 3306 is the default port for the classic MySQL protocol ( port ), which is used by the mysql client, MySQL Connectors, and utilities such as mysqldump and mysqlpump.
Use -P
parameter, like this:
mysql -h 127.0.0.1 -P 3307 -u user_name -p database_name
Important: if you connecting to localhost
- use -h 127.0.0.1
, NOT localhost
, because MySQL will connect by file socket, not by TCP
From command line, assuming you are on the same host, have you tried :
mysql --user root --password (mypassword) --host=localhost --port=33061
In server name specify custom port when not using default one (you can imply it only when is the standard mysql port 3306)
$servername = "localhost:33061";
you can use -P (uppercase) or --port=portnumber sample
mysql -u root -P 13306 -p databasename
or
mysql -u root --port=13306 -p databasename
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With