I have 2 mysqld.exe, one from phpMyAdmin and one from MySQL server. I use the command line command "mysql -u root -p" to connect, how do i get this command to connect to MySQL server (port 3307) by default, instead of phpMyAdmin (port 3306). It is fine to add "-P 3307", but I only want to use the command "mysql -u root -p". This command("mysql -u root -p") used to connect to port 3307, i don't know what made it change. How can i connect to port 3307 by default.
Asked
Active
Viewed 88 times
0
-
Why do you have two "mysqld.exe" instances? phpMyAdmin is only a MySQL administration tool/client, it does not come itself with a MySQL server. – Progman Aug 27 '22 at 11:45
-
I'm a little fuzzy on these concepts, maybe it came from the mysql module in XAMPP which I set to port 3306. Then I downloaded MySQL Community Server 8.0.30 which is set to port 3307. now using the command line "mysql -u root -p" which connects to port 3306 by default, specify " mysql -u root -p -P 3307" will connect to port 3307. But I want to make the default connection point to port 3307 and now I don't know how to handle it. – c2wind Aug 27 '22 at 12:38
-
Just change the my.ini file, (and remember what you changed) Restart the services, and see what result you get because of this change. When it breaks you can always undo the change! Do it step-by-step and you wil notice that it's not hard to do. – Luuk Aug 27 '22 at 12:43
-
@chenty-wind When MySQL already come with the XAMPP package, why do you install a second MySQL server? – Progman Aug 27 '22 at 12:49
-
@Luuk Thank's for your guidance . I'll try it. – c2wind Aug 27 '22 at 13:26
-
@Progman I load XAMPP package two years ago. I recently followed a tutorial to learn MySQL, so i load MySQL server 8. I've thought about uninstalling xampp, but I wanted to see what the exact conflict was like and whether it would be compatible...so... – c2wind Aug 27 '22 at 13:31
1 Answers
1
Edit my.cnf and add port 3307 (or the one you want to be defaulted), then restart the service and you should be good.
on my.cnf be sure to have this:
port=3307
to find my.cnf file in linux or windows bash use: sudo find / -name "my.cnf"

jmvcollaborator
- 2,141
- 1
- 6
- 17
-
When you change (or add) the `port` in the section `[client]`, there is no need to restart the service, because that setting will be used by the client only. – Luuk Aug 27 '22 at 11:20
-
Thanks. I have two my.ini files, one in the "MySQL Server 8" folder with port = 3307 and the other in the "xampp/mysql/bin" folder with port = 3306. I want to use "mysql -u root -p" to connect to port = 3307, but it connects to port = 3306 by default. I am new to MySQL and I hope I have clarified the problem. – c2wind Aug 27 '22 at 11:26
-
1@chenty-wind Check https://stackoverflow.com/questions/2482234/how-do-i-find-the-mysql-my-cnf-location on how to find the correct location of the "my.cnf" file, also check https://dev.mysql.com/doc/refman/8.0/en/option-files.html – Progman Aug 27 '22 at 11:46