Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change port # for mysql on mac

Tags:

mysql

I just installed mysql on a mac running 10.6. The mysql version is 5.1.56. I need to have mysql run on port 3307. This article says we can change the port by modifying this file:

# vi /etc/my.cnf

http://www.cyberciti.biz/faq/change-default-mysql-port-under-linuxunix/

but there is no such file in /etc. I can see mysql is running ok because I can connect to it just fine, is the way we change the port # different now?

Thanks

like image 991
user291701 Avatar asked Mar 16 '11 02:03

user291701


People also ask

Can we change port number?

If you do not want to use the default port numbers for the application servers, you can change them.

How do I change the port number on my computer?

How to Change My Port Number 1 Find PortNumber 2 Click Edit > Modify, and then click Decimal. 3 Type the new port number, and then click OK. 4 Close the registry editor, and restart your computer. See More....

How do I change the default port number for RDP?

Start the registry editor. (Type regedit in the Search box.) Navigate to the following registry subkey: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\PortNumber. Click Edit > Modify, and then click Decimal. Type the new port number, and then click OK.

What does the change PORT command do in Linux?

The change port command maps a serial port to a different port number, allowing apps that don't support high-numbered COM ports to access the serial port. Remapping works only for the current session and is not retained if you log off from a session and then log on again.

How do I change the port size for legacy applications?

However many legacy applications expect the port to be between 1-4. Let’s change that:Right click on the device and click on ‘Properties’. Click on ‘Port Settings’. Then click on ‘Advanced…’.


5 Answers

Looks like the new installers are adding the port as 3307

To change that follow below steps

sudo vi /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
change 3307 from this line <string>--port=3307</string> to 3306
like image 189
vijayan007 Avatar answered Oct 01 '22 22:10

vijayan007


On OSX you can create /etc/my.cnf if it does not exist. You can base it on samples found in /usr/local/mysql/support-files. Don't forget to restart MySQL for your my.cnf to take effect.

like image 35
Asaph Avatar answered Oct 02 '22 00:10

Asaph


On MacOs High Sierra running MySql v8 server, you need the following:

  1. Edit /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

  2. Under ProgramArguments, you will see many entries with <string>...</string> etc,

  3. Add the following line: <string>--port=16000</string>

Also, to restart you need to do the following:

launchctl unload -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

and then

launchctl load -F /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist

I hope this helps.

like image 35
Heider Sati Avatar answered Oct 01 '22 22:10

Heider Sati


By default, the install doesn't create a my.cnf file on Snow Leopard. You can create one yourself under /etc or you can copy one from /usr/local/mysql/support-files/

Then run : sudo cp my-huge.cnf /etc/my.cnf

Check out the explanation here

like image 44
Dominic Tancredi Avatar answered Oct 01 '22 22:10

Dominic Tancredi


I experienced a similar problem and here's what worked for me. If you installed MySQL using brew install mysql then this should work for you. For context, I'm using macOS Monterey 12, Homebrew 3.4.5, and MySQL 8.0.

MySQL is installed in: /opt/homebrew/Cellar/mysql/8.0.28_1/

The configuration file my.cnf is located at /opt/homebrew/etc.

You can change the default port by specifying a new port in the my.cnf file.

First navigate to the homebrew etc folder

cd /opt/homebrew/etc

Append the new port value to the my.cnf file

echo "port = 3307" >> my.cnf

restart the MySQL service

brew services restart mysql
like image 38
Chidiebere Nwachukwu Avatar answered Oct 02 '22 00:10

Chidiebere Nwachukwu