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

car*_*aro 10 mysql ubuntu lamp my.cnf

我试图将一个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/
Run Code Online (Sandbox Code Playgroud)

car*_*aro 20

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

  • 你不是傻瓜,我也花了"10"小时寻找这个)) (2认同)

lin*_*jie 9

在ubuntu 15.04中,MySQL Server配置文件位于:

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

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

service mysql restart

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

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

netstat -tap | grep mysql
Run Code Online (Sandbox Code Playgroud)

所以你知道配置是否生效.


BK4*_*435 0

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

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

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

bind-address = 127.0.0.1

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

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

show grants for 'youruser'@'yourhost';

Mysql的授予和特权。