mysql 5.6 ubuntu 15.04 找不到正确的 my.cnf 文件

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

mysql 5.6 ubuntu 15.04 cannot find correct my.cnf file

mysqlubuntulampmy.cnf

提问by caro

I am attempting to move a mysql db onto an upgraded server with a newer version of ubuntu running (15.04), and after installing LAMP, I went to edit the bind address in the my.cnf file. The below is all I see in /etc/mysql/my.cnf. I added [mysqld] and the bind address = new address but nothing seems to allow my remote client to connect to this db. It is online and the ip address should be correct. What am i missing? Why is this my.cnf so bare?

我试图将 mysql db 移动到运行较新版本的 ubuntu (15.04) 的升级服务器上,安装 LAMP 后,我去编辑 my.cnf 文件中的绑定地址。以下是我在 /etc/mysql/my.cnf 中看到的所有内容。我添加了 [mysqld] 和绑定地址 = 新地址,但似乎没有任何东西允许我的远程客户端连接到这个数据库。它是在线的,IP地址应该是正确的。我错过了什么?为什么这个 my.cnf 这么空?

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

回答by caro

stupid me, apparently in this version it is the mysqld.cnf under /etc/mysql/mysql.conf.d/. Oh well. Posting this in case anyone else has problems.....

愚蠢的我,显然在这个版本中它是/etc/mysql/mysql.conf.d/下的mysqld.cnf。那好吧。发布这个以防其他人有问题......

回答by linjie

In ubuntu 15.04 the MySQL Server configure file is in:

在 ubuntu 15.04 中,MySQL 服务器配置文件位于:

/etc/mysql/mysql.conf.d/mysqld.cnf

/etc/mysql/mysql.conf.d/mysqld.cnf

You can find bind-addresshere.Comment it, and restart your MySQL Server use :

你可以在这里找到。bind-address评论它,并重新启动你的 MySQL 服务器使用:

service mysql restart

service mysql restart

Then you can access your MysqlServer from other computer. If you don't, perhaps you need grant some right to the user you use.

然后您可以从其他计算机访问您的 MysqlServer。如果您不这样做,也许您需要向您使用的用户授予一些权利。

You can see MySQL Server bind-address use:

你可以看到 MySQL Server 绑定地址的用法:

netstat -tap | grep mysql

So you know whether the configure take effect.

这样你就知道配置是否生效了。

回答by BK435

Depending on your linux distro your my.cnf (as well as the rest of your data directory) may be in /var/lib/mysql folder.

根据您的 linux 发行版,您的 my.cnf(以及您的数据目录的其余部分)可能位于 /var/lib/mysql 文件夹中。

You could also run the find command to look for the file: find -name 'my.cnf'. I suggest running this command as root, in your root directory.

您还可以运行 find 命令来查找文件:find -name 'my.cnf'. 我建议在您的根目录中以 root 身份运行此命令。

Once you have located the correct my.cnf file there will be a parameter under [mysqld]section that looks like this:

找到正确的 my.cnf 文件后,[mysqld]部分下将有一个参数,如下所示:

bind-address = 127.0.0.1

bind-address = 127.0.0.1

Comment this parameter out with a #and save the edited my.cnf file. Restart the Mysql server and you should be able to connect remotely from any IP as long as the user you are trying to connect with as the correct permissions and host(%).

用 a 注释掉这个参数#并保存编辑过的 my.cnf 文件。重新启动 Mysql 服务器,只要您尝试连接的用户具有正确的权限和主机(%),您就应该能够从任何 IP 远程连接。

You can check this by running: select user, host from mysql,user;

您可以通过运行来检查: select user, host from mysql,user;

and show grants for 'youruser'@'yourhost';

show grants for 'youruser'@'yourhost';

grants and privileges for Mysql.

Mysql 的授权和特权。