在 mac 上更改 mysql 的端口号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5320424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change port # for mysql on mac
提问by user291701
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:
我刚刚在运行 10.6 的 mac 上安装了 mysql。mysql 版本是 5.1.56。我需要让mysql运行在3307端口。这篇文章说我们可以通过修改这个文件来改变端口:
# vi /etc/my.cnf
http://www.cyberciti.biz/faq/change-default-mysql-port-under-linuxunix/
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?
但是 /etc 中没有这样的文件。我可以看到 mysql 运行正常,因为我可以很好地连接到它,现在我们更改端口的方式是否有所不同?
Thanks
谢谢
采纳答案by Asaph
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.
在 OSX 上,/etc/my.cnf
如果它不存在,您可以创建。您可以基于/usr/local/mysql/support-files
. 不要忘记重新启动 MySQL 以my.cnf
使其生效。
回答by Vijayan Srinivasan
Looks like the new installers are adding the port as 3307
看起来新安装程序将端口添加为 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
回答by Dominic Tancredi
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/
默认情况下,安装不会在 Snow Leopard 上创建 my.cnf 文件。您可以在 /etc 下自己创建一个,也可以从 /usr/local/mysql/support-files/ 复制一个
Then run :
sudo cp my-huge.cnf /etc/my.cnf
然后运行:
sudo cp my-huge.cnf /etc/my.cnf
Check out the explanation here
查看这里的解释
回答by Heider Sati
On MacOs High Sierra running MySql v8 server, you need the following:
在运行 MySql v8 服务器的 MacOs High Sierra 上,您需要以下内容:
Edit
/Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
Under
ProgramArguments
, you will see many entries with<string>...</string>
etc,Add the following line:
<string>--port=16000</string>
编辑
/Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
在 下
ProgramArguments
,您会看到许多带有<string>...</string>
etc 的条目 ,添加以下行:
<string>--port=16000</string>
Also, to restartyou 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.
我希望这有帮助。
回答by Evan Erickson
I installed docker and was having problems with my company wanting to use port 3306 (which is what I was using privately).
我安装了 docker,但我的公司想要使用端口 3306(这是我私下使用的端口)时遇到了问题。
Similar problem to you. So this is what I did to fix it.
和你类似的问题。所以这就是我为修复它所做的。
sudo vi /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
sudo vi /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
Then you get a long list of script tags and
然后你会得到一长串脚本标签和
Insert <string>--port=3307</string>
into the array. Make sure you put it under the other strings and within the array.
插入<string>--port=3307</string>
数组。确保将它放在其他字符串下和数组内。
I changed my port to 3307 instead of 3306 and now docker is working.
我将端口更改为 3307 而不是 3306,现在 docker 正在工作。
回答by webnuts.io
I tried a long time to get mysql running on my Mac (OSX 10.11.13) with mysql 5.7.11 to develop wordpress sites on my local machine...
我尝试了很长时间让 mysql 在我的 Mac(OSX 10.11.13)和 mysql 5.7.11 上运行,以在我的本地机器上开发 wordpress 网站......
When I used the app duplicator to migrate a website to my local machine I got errors during the database import. This was caused by to stricked sql_mode...
当我使用应用程序复制器将网站迁移到我的本地机器时,我在数据库导入过程中遇到了错误。这是由于 sql_mode...
The trick that made it was:
制作它的技巧是:
Going to
即将
/usr/local/mysql-5.7.11/support-files/
and copy the content from my-default.cnf
并从中复制内容 my-default.cnf
and paste it to
并将其粘贴到
/etc/my.cnf
(if this file does not exist create it!)
/etc/my.cnf
(如果此文件不存在,请创建它!)
at the very last line of my.cnf
I added:
在my.cnf
我添加的最后一行:
sql_mode="NO_ENGINE_SUBSTITUTION"
Et voilà: sql_mode is changed permanently!
等等:sql_mode 已永久更改!
Whoop whoop!
呜呜呜!