【问题标题】:mysql 5.6 ubuntu 15.04 cannot find correct my.cnf filemysql 5.6 ubuntu 15.04 找不到正确的 my.cnf 文件
【发布时间】:2015-08-18 13:05:17
【问题描述】:

我正在尝试将 mysql 数据库移动到运行新版本 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/

【问题讨论】:

    标签: mysql ubuntu lamp my.cnf


    【解决方案1】:

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

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

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

    bind-address = 127.0.0.1

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

    您可以通过运行以下命令进行检查: select user, host from mysql,user;

    show grants for 'youruser'@'yourhost';

    Mysql 的授权和特权。

    【讨论】:

    • 我找到了,/etc/mysql/my.cnf 是唯一的位置——我发布的是它包含的所有内容,这让我很害怕。我完全习惯于编辑绑定地址行。我应该假设 LAMP 安装没有正确安装 MySQL 吗?我试图将以前的 my.cnf 复制到那个文件中,但它仍然不允许我远程连接。
    • 我实际上并没有这样做,我正在接管这个项目,但我相信它是使用 LAMP 安装的 Ubuntu 15.05 映像文件
    【解决方案2】:

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

    【讨论】:

    • 在这一行 - !includedir /etc/mysql/conf.d/, 做“!”是指不包括还是包括?
    • 你不傻,我也花了“10”个小时寻找这个))
    • 即使这个文件也有与上面相同的注释行。我找不到绑定地址
    • so /etc/mysql/mysql.conf.d/mysqld.cnf 对于任何想要快速复制粘贴的人。
    【解决方案3】:

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

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

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

    service mysql restart

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

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

    netstat -tap | grep mysql
    

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

    【讨论】:

    • 我的安装还有一个 /etc/mysql/my.cnf 文件(这是指向 my.cnf -> /etc/alternatives/my.cnf 的符号链接)。哪个配置文件是用于自定义设置的“正确”配置文件?编辑 /etc/mysql/my.conf 还是 /etc/mysql/mysql.conf.d/mysqld.cnf 更好?
    猜你喜欢
    • 2016-11-12
    • 2017-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-17
    • 2015-08-24
    相关资源
    最近更新 更多