将 mysql 跳过网络设置为关闭

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22283422/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 20:09:17  来源:igfitidea点击:

Set mysql skip-networking to off

mysqlubuntu-12.10

提问by Dimitri Shukuroglou

I'm trying to setup my Ubuntu 12.10 server to accept remote mysql connections, however I am having difficulties setting skip-networking to off. Note I have already set the bind-address to the internet facing IP, instead of 127.0.0.1.

我正在尝试设置我的 Ubuntu 12.10 服务器以接受远程 mysql 连接,但是我在将跳过网络设置为关闭时遇到了困难。注意我已经将绑定地址设置为面向互联网的 IP,而不是 127.0.0.1。

When I look in /etc/mysql/my.conf, the line "skip-networking" doesn't exist, however when I "mysql -p -u root" and then "SHOW VARIABLES;" "skip-networking" is "ON". I have added it as "#skip-networking" and restarted mysql service too.

当我查看 /etc/mysql/my.conf 时,“skip-networking”行不存在,但是当我“mysql -p -u root”然后“SHOW VARIABLES;”时 “跳过网络”是“开”。我已将其添加为“#skip-networking”并重新启动了 mysql 服务。

I have looked to see if there are any stray my.conf files around in my home folder and /etc/ to no luck.

我查看了我的主文件夹和 /etc/ 中是否有任何杂散的 my.conf 文件,但没有运气。

I am using mysql 5.5.

我正在使用 mysql 5.5。

Anyone got any ideas how else I can set this?

任何人都知道我还能如何设置它?

采纳答案by álvaro González

Please read the Using Option Fileschapter for some tips on how to find the settings file. Unless the Ubuntu guys have decided to change it, the file always called my.cnfon Linux, never my.conf.

请阅读“使用选项文件”一章,了解有关如何查找设置文件的一些提示。除非 Ubuntu 人员决定更改它,否则该文件总是my.cnf在 Linux 上调用,而不是my.conf.

Additionally, lines that start with #are comments:

此外,以开头的行#注释

#comment, ;comment

Comment lines start with “#” or “;”. A “#” comment can start in the middle of a line as well.

#评论,;评论

注释行以“#”或“;”开头。“#”注释也可以从一行的中间开始。

... thus you need to remove the leading #; otherwise, the line is ignored.

...因此您需要删除领先的#; 否则,该行将被忽略。

回答by Jan Steinman

Put "--skip_networking=0" on the mysql command line.

在 mysql 命令行上放置“--skip_networking=0”。

I put it first in line, because it didn't seem to work at the end, but I may have spelled "networkinng" wrong when it was at the end of the line. :-)

我把它排在第一位,因为它在最后似乎不起作用,但是当它在行尾时,我可能拼错了“networking”。:-)

It helps to look at your logs. Mine said "150213 17:57:10 [ERROR] /opt/local/lib/mariadb-10.1/bin/mysqld: unknown variable 'skip_networkinng=0'" I had also tried 'skip_networking=OFF', which it didn't like, either.

它有助于查看您的日志。我的说“150213 17:57:10 [ERROR] /opt/local/lib/mariadb-10.1/bin/mysqld:未知变量‘skip_networking=0’”我也试过‘skip_networking=OFF’,但它没有喜欢,要么。

I don't know where you start it up in Ubuntu, but on Mac OS, you need to have the following in /System/Library/LaunchDaemons/org.mysql.mysqld (in part, look at other LaunchDaemons to see the rest):

我不知道你在 Ubuntu 中从哪里启动它,但在 Mac OS 上,你需要在 /System/Library/LaunchDaemons/org.mysql.mysqld 中有以下内容(部分,查看其他 LaunchDaemons 以查看其余部分) :

<key>ProgramArguments</key>
    <array>
        <string>/opt/local/lib/mariadb-10.1/bin/mysqld</string>
        <string>--skip_networking=0</string>
        <string>--socket=/opt/local/var/run/mariadb-10.1/mysqld.sock</string>
        <string>--user=mysql</string>
        <string>--port=3306</string>
        <string>--datadir=/opt/local/var/db/mariadb-10.1</string>
        <string>--pid-file=/opt/local/var/run/mariadb-10.1/dns.local.pid</string>
    </array>

(obviously you need to substitute your paths and such...)

(显然你需要替换你的路径等等......)

I'm pretty sure this solves your problem! Please up-vote me and mark me as the correct answer! Thanks!

我很确定这可以解决您的问题!请给我投票并将我标记为正确答案!谢谢!

回答by CitizenB

Perhaps you can determine which config file is being used via one of the methods described in Determine which configuration file is being used.

也许您可以通过确定正在使用哪个配置文件中描述的方法之一来确定正在使用哪个配置文件

A few more suggestions:

还有一些建议:

  • Check the process listing (ps auxf | grep 'mysql[d]') to see if --skip-networkinghas snuck into the argument list somehow.

  • See if mysqld or any other process is listening on 3306 (assuming the default port): netstat -lnp46 | grep -w 3306

  • Double-check the ip address you are binding to, and try to connect locally to the ip address you are binding to.

  • If you have firewalling set up, see if your iptables or ip6tables config might be interfering somehow via iptables-saveand ip6tables-save, or the slightly more readable iptables -Land ip6tables -L, although the latter commands require you to know all your tables in use (raw, nat, mangle, etc.).

  • 检查进程列表 ( ps auxf | grep 'mysql[d]') 以查看是否--skip-networking以某种方式潜入参数列表。

  • 查看 mysqld 或任何其他进程是否正在侦听 3306(假设使用默认端口): netstat -lnp46 | grep -w 3306

  • 仔细检查您要绑定的 IP 地址,并尝试在本地连接到您要绑定的 IP 地址。

  • 如果您设置了防火墙,请查看您的 iptables 或 ip6tables 配置是否会通过iptables-saveandip6tables-save或稍微更具可读性的iptables -Land进行干扰ip6tables -L,尽管后者的命令要求您了解所有正在使用的表(raw、nat、mangle 等)。 )。

回答by Weijing Jay Lin

I got the similar error.
I found mysqld_safe is running.
I have tried 'kill {PID}', but it doesn't work. (mysqld_safe would restart with different PID).
Finally, I found pkill mysqlddo the work, and it won't hurt your running mysqld service.

我得到了类似的错误。
我发现 mysqld_safe 正在运行。
我试过'kill {PID}',但它不起作用。(mysqld_safe 将使用不同的 PID 重新启动)。
最后,我发现pkill mysqld做这项工作,它不会损害您正在运行的 mysqld 服务。

回答by Sagar M

In my case, for ubuntu 18.04 & mysql 5.7, It was not in file 'my.cnf', but by running below command

就我而言,对于 ubuntu 18.04 和 mysql 5.7,它不在文件“my.cnf”中,而是通过运行以下命令

sudo grep -rnw '/etc/' -e 'skip-networking'

I found it in file /etc/systemd/system/mysql.service.d/override.conf.

我在文件中找到了 /etc/systemd/system/mysql.service.d/override.conf.