Take the Win7 system, MySQL version 5.5.57 as an example:
- View the port number of the native MySQL (default is 3306)
- Open a DOS window
Win+r Open the Run interface input cmd or enter CMD in the Start menu search box and return
2. Connect to MySQL Service
Enter Mysql-u root-p and then enter
3. Continue to enter the password, and then enter:
4. The following interface shows the successful connection to MySQL service
5. Enter the command to view the port number:show global variables like ' port ';
6. For example, 3306 is the port number of the current MySQL service
- If you want to modify the port number of MySQL, the following actions are required:
- Locate the My.ini file in the MySQL installation directory
2. Open through the tool, I use notepad++ ctrl+f search for the MySQL port number we found just now, the default is 3306, we have not changed before, so is 3306. It will be found that there are two "port=3306" in lines 53 and 70, both of which need to be changed. Change to the new port number you want to set (the port number range is 0-65535). (I changed it to 3396)
3. After the My.ini file is changed and saved, we need to restart the MySQL service. Otherwise, the connection cannot be successful.
4. On the desktop, find "My Computer" right click and select "Manage"
5. Find "Services and Applications" and double-click
6. Continue to double-click "Services"
7. Find "MySQL" in the list and right click to select "Restart"
8. Wait for the restart ING
After the reboot is complete, check to see if the change was successful, as we have just looked at the MySQL port number.
, 3396 is the port number I changed.
How to view and modify the port number of MySQL under Windows