简体   繁体   中英

XAMPP MySQL port 3306 not changing

I have seen all the posts and did all the changes, but when I run XAMPP MySQL, it opens 3306 and closes, it is not going to 3307 port.

I have changed xampp\\mysql\\bin\\my.ini all port number 3306 to 3307 and even xampp\\php\\php.ini changed 3306 to 3307, even all the .ini files in MySQL that had 3306 changed to 3307. Went to processes and services removed XAMPP as well.

Restarted my PC as well.

Anyone has any idea where to make changes that XAMPP will look at 3307 port for MySQL?

You have to set it in the settings of xamp also. Open the control center and go to Config (right side, first option). There you find something like "Services and ports". Here you can change the ports data for all apps in xamp.

Just don't forget to change the other line below here you changed.

# password = your_password 
port = 3366   <----------------------------

skip-grant-tables           
port = 3305   <--------------------------

Most of the people who have answered this question have not written the entire procedure. Here is the complete procedure for changing the Mysql port in XAMPP :

If you are not able to start MySql service in Xampp, conflicting ports might be the culprit. Some other applications might be using the default Mysql port(3306). You can find which application is using this port using CMD command : **netstat -ano | findstr 3306 ** . If you get any result for this command, then the port 3306 is active. You can manually stop it by writing services.msc in RUN dialog, finding this service and then finally stopping it. However, this solution is temporary. After every restart, you'll have to manually stop this service. Other option is to change the port of MySQL Xampp from 3306 to something else(like 3308). Here is how to do it :

  1. Open Xampp.
  2. Stop all the running services.
  3. Go to " config " at top-right corner of the Xampp window, click on " service and port settings ", go to " mysql " tab and change the " main port " to 3308 or something else.
  4. Now, in Xampp, click on " config " in the Mysql row (click on Mysql's "config"), and open " my.ini ".
  5. " my.ini " will open in notepad. Go to Line 20 (Can be some other line also) and change the port to 3308. Like this:

# password = your_password

port = 3308

  1. Also, change the port to 3308 on line 28 of my.ini file, like this:

# The MySQL server

[mysqld]

port= 3308

  1. Save the changes.
  2. Restart the Xampp. You might also have to restart your device.
  3. Now go to C:\\xampp\\phpMyAdmin(Your directory where Xampp is installed) . Open the " config.inc.php " file.
  4. Below the user, password and extension lines at the top of file(Below line 23), add this line:

$cfg['Servers'][$i]['port'] = 3308;

(Other wise this error will occur in while opening " phpmyadmin ": (HY000/2002): No connection could be made because the target machine actively refused it.

  1. Save the changes.

  2. Now, you have to mention this new port in your project code :

//After adding the port:

$conn = mysqli_connect("localhost:3308" , "root" , "", "database_name");

That's it.

Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM