对my.cnf所做的更改不会生效(Ubuntu 16.04,mysql 5.6) [英] Changes to my.cnf don't take effect (Ubuntu 16.04, mysql 5.6)
问题描述
我对my.cnf所做的更改似乎对mysql环境没有任何影响.这是发生的事情的摘要...
Changes I make to my.cnf don't seem to have any effect on the mysql environment. Here's a summary of what's happened...
我在Ubuntu 16.04上安装了mysql 5.7,但是由于不兼容的问题,我意识到我需要降级到mysql 5.6.
I installed mysql 5.7 on Ubuntu 16.04 but then realized I needed to downgrade to mysql 5.6 due to incompatibility issues.
我倾向于清除相关应用程序,然后删除/etc/mysql和/var/lib/mysql等所有剩余目录
I apt purged the related applications and then removed any remaining directories such at /etc/mysql and /var/lib/mysql
然后我安装了mysql-5.6(服务器和客户端)以及相关的软件包.
I then installed mysql-5.6 (server and client) and related packages.
我能够从同样运行mysql 5.6的服务器上的转储中加载一个数据库,但是当我试图从同一台服务器的第二个转储中加载第二个数据库时,出现了此错误:
I was able to load one database from a dump from a server also running mysql 5.6 but when I tried to load a second database from a second dump from that same server, I got this error:
ERROR 2006 (HY000) at line 1721: MySQL server has gone away
当我用Google搜索时,我看到结果说要通过my.cnf文件设置各种选项.
When I Googled that, I saw results saying to set various options via the my.cnf file.
我跑步时...
updatedb && locate my.cnf
...我只看到四个结果,所有结果都链接回同一文件:/etc/mysql/my.cnf.fallback.例如. /etc/mysql/my.cnf.fallback ==/etc/mysql/my.cnf
...I only see four results which are all links back to the same file: /etc/mysql/my.cnf.fallback. E.g. /etc/mysql/my.cnf.fallback == /etc/mysql/my.cnf
根主目录或用户的主目录中都没有.my.cnf文件.我将错字放入my.cnf文件中,然后重新加载了mysql,以查看预期的错误并知道文件正在加载.然后,我删除了错误的代码并添加了以下内容:
There are no .my.cnf files in either the root home directory or my user's home directory. I put a typo into the my.cnf file and reloaded mysql just to see the expected error and know the file was being loaded. I then removed the erroneous code and added the following:
[mysqld]
max_allowed_packet=1073741824
然后我通过各种方式运行来重新加载mysql:
I then reloaded mysql by running in various ways:
service mysql restart
或
service mysql stop
service mysql start
或
/etc/init.d/mysql stop
/etc/init.d/mysql start
然后我继续获取该默认值,表明未从my.cnf进行设置:
I then kept getting this default value indicating that it was not getting set from my.cnf:
mysql> SHOW VARIABLES LIKE 'max_allowed_packet';
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 4194304 |
+--------------------+---------+
如果我这样做:
mysql> SET GLOBAL max_allowed_packet=1073741824;
然后注销并返回到mysql客户端,我看到正确的值:
and log out and back into the mysql client, I see the correct value:
mysql> SHOW VARIABLES LIKE 'max_allowed_packet';
+--------------------+------------+
| Variable_name | Value |
+--------------------+------------+
| max_allowed_packet | 1073741824 |
+--------------------+------------+
但是,当然,如果我重新启动mysql服务器,该值将恢复.
But of course, if I restart the mysql server, the value reverts.
我已经用尽了搜索能力.我可能做错了什么?
I've exhausted my search ability. What can I possibly be doing wrong?
推荐答案
显然,my.cnf.fallback不是正确的配置文件.
Obviously my.cnf.fallback is not the correct configuration file.
如果尝试使用此命令,则可以获取可能的my.cnf位置的输出:
If you try this commands you can get output for possible my.cnf locations:
$ which mysqld
/usr/sbin/mysqld
$ /usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"
Default options are read from the following files in the given order:
/etc/mysql/my.cnf ~/.my.cnf /usr/etc/my.cnf
这意味着mysql将检查my.cnf文件的位置.只需将/etc/mysql/my.cnf.fallback
重命名为/etc/mysql/my.cnf
:
It means mysql will check those locations for my.cnf file. Simply rename /etc/mysql/my.cnf.fallback
as /etc/mysql/my.cnf
:
mv /etc/mysql/my.cnf.fallback /etc/mysql/my.cnf
这篇关于对my.cnf所做的更改不会生效(Ubuntu 16.04,mysql 5.6)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!