How to Change the MySQL Port on Windows and in Workbench

Watch the full tutorial:

MySQL Server on Windows listens on port 3306. Change that when another database, usually XAMPP, needs 3306, or when you are standardizing on 3307. Workbench will not reconnect until its connection uses the same port.

This is the Windows service install, not the XAMPP copy of MySQL. XAMPP has its own my.ini under C:xamppmysqlbin, covered in the XAMPP port guide.

Stop MySQL before you edit

  1. Open the Start menu and search for Services.
  2. Find MySQL80.
  3. Right-click it and choose Stop.

Editing the file while the service is running can lose the change the next time the service writes config, and a running server will not pick up the new port until a restart anyway.

Open the hidden my.ini

  1. In File Explorer, open the View menu and turn on Hidden items. ProgramData does not show otherwise.
  2. Go to C:ProgramDataMySQLMySQL Server 8.0.
  3. Right-click my.ini and open it in Notepad. If Windows refuses to save later, the permissions tutorial next in this series is the fix: give your user Full control on that file, then come back. That permission step is in this same video.

Change both port lines

Search for 3306. Update the port in both sections:

[client]
port=3307

[mysqld]
port=3307

Save the file. Start MySQL80 again from Services.

Update Workbench

  1. Open MySQL Workbench.
  2. Right-click the local connection and choose Edit Connection.
  3. Change the port from 3306 to 3307.
  4. Close the dialog and connect with the root password.

From a terminal, you can also connect with an explicit port:

mysql -u root -p -P 3307

The capital P is the port flag. A lowercase p means “ask for the password.”

Disclaimer

Sengideons.com does not host any files on its servers. All point to content hosted on third-party websites. Sengideons.com does not accept responsibility for content hosted on third-party websites and does not have any involvement in the same.

LEAVE A REPLY

Please enter your comment!
Please enter your name here
Are you human? Please solve:Captcha