Recommended Free Tools
To change the local MySQL server’s classic-protocol TCP port, set port=13306 under the server’s [mysqld] section in the option file it reads, then restart MySQL. The documented default is 3306. After the restart, connect over TCP using the new port. The exact option-file path and restart method depend on how MySQL was installed.
Which MySQL port are you changing?
MySQL’s classic protocol uses TCP port 3306 by default. MySQL Installer documentation for MySQL 8.0 lists 33060 as the separate default for X Protocol. These are distinct listeners: changing the classic-protocol port does not, by itself, change the X Protocol port. See the MySQL Installer server configuration settings and the MySQL Port Reference.
This guide changes the server’s local classic-protocol TCP listener. It does not configure remote access, change a client’s socket connection, or necessarily alter X Protocol.
Choose how to set the port
| Method | Best fit | What to know |
|---|---|---|
| Server option file | A setting that should persist across normal service starts. | Add port=13306 under [mysqld] in an option file the server actually reads. Restart MySQL for the setting to take effect. |
| Server startup option | A startup command or service configuration that you manage directly. | Start the server with --port=13306. The setting applies when that startup command is used; it is not a dynamic runtime change. |
| MySQL Installer on Windows | Configuring an installation through the Windows Installer interface. | The MySQL 8.0 Installer configuration flow includes a classic-protocol port setting and a separate X Protocol port setting. Screen labels can vary by release. |
MySQL documents port as a server startup option with a default of 3306; it is not dynamic, so restart the server after changing it. The server’s port option documentation describes the setting and its behavior.
#1 Best Overall
How do I change MySQL from port 3306?
1. Find the option file MySQL reads
Do not assume every installation uses the same my.cnf or my.ini path. MySQL can read multiple candidate option files, and a later file in the documented search order can override an earlier value. On Unix-like systems, MySQL ignores world-writable option files. Check the documentation for your release and installation to identify the active file and its precedence before editing it. See MySQL option files.
On Windows, MySQL Installer creates a my.ini file for the configured server. On non-Windows installations, the cited MySQL documentation says installation and data-directory initialization do not create a default option file. If none exists, create one following the documented option-file instructions and ensure the server can find it. See MySQL option-file locations and server configuration defaults.
2. Set the port in the server section
In the option file, add or update the setting in the [mysqld] section. For example, to use port 13306:
[mysqld]
port=13306
If the file already has a [mysqld] section, put the setting inside that section rather than creating a duplicate section. Choose a port available to the server. On Unix-like systems, ports below 1024 require the server to run as root; do not run MySQL as root just to use a low port. Select a suitable unprivileged port instead.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →3. Restart MySQL using your installation’s service method
The change takes effect at server startup. Restart the MySQL service using the service manager, package instructions, or Windows service controls that apply to your installation. There is no single restart command that is correct for every operating system and package. If you used a startup command rather than an option file, ensure the service or server launch configuration includes --port=13306 whenever the server starts.
4. Connect with the new TCP port
For a local TCP connection, specify the new port and use 127.0.0.1 as the host:
Rank #4
mysql --host=127.0.0.1 --port=13306 -u your_user -p
Alternatively, force TCP explicitly:
mysql --protocol=TCP --host=localhost --port=13306 -u your_user -p
Enter the account password when prompted. The client’s port must match the server’s TCP listener. The MySQL client documentation explains its connection protocol and host behavior: connecting to the MySQL server.
Why is MySQL ignoring my port setting on localhost?
On Unix-like systems, a client connection to localhost normally uses a Unix socket rather than TCP. In that case, specifying --port may have no effect because the connection is not using a TCP port. Use --host=127.0.0.1 or add --protocol=TCP to test the TCP listener, as in the examples above.
Troubleshoot a port change
The server fails to start with a bind error
An “address already in use” or similar bind failure usually means another process already owns the chosen port. Identify the process using it; it may be another MySQL server. Stop or reconfigure that process, or choose an available port, then make the server and TCP clients use the same port. MySQL’s connection troubleshooting documentation covers common server connection failures.
The server starts, but the local client cannot connect
- Confirm that the client is using TCP, not a Unix socket, and that its port matches the server’s configured port.
- Check that the server successfully restarted with the option file or startup setting you changed; another option file later in the search order may override the value.
- Check whether the server is listening on the expected interface and whether a firewall or endpoint security rule blocks the connection.
- Check that
skip_networkingis not enabled; it disables TCP/IP networking.
See the MySQL documentation for the skip_networking option and the bind_address option.
Remote clients cannot connect after the change
A local port change does not enable remote access. For example, bind_address=127.0.0.1 restricts TCP listening to loopback, so other computers cannot reach the server through that listener. Remote access may also be blocked by firewall rules. Change the listening interface and firewall only when remote access is required, and restrict access to the intended clients.
Windows Firewall or Linux security controls block access
MySQL Installer offers to open a Windows Firewall port when configuring network access; if connections still fail, check the applicable Windows Firewall and endpoint-filtering rules. For Linux, package installations may help configure SELinux or AppArmor, but less common port configurations can require additional distribution-specific handling. A firewall rule alone may not be sufficient. The MySQL Port Reference recommends applying least privilege to port access.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteQuick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

