所以 mysqldump 抛出以下错误:
mysqldump: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 22!
mysqldump: [ERROR] Fatal error in defaults handling. Program aborted!
我的 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/
event-scheduler=ENABLED
附带问题:我应该在我的配置文件中添加一些内容以提高安全性吗?我能以某种方式压缩我的表吗,最好是使用 phpmyadmin?
您可能会看到此消息的原因有两个:
原因一
您的
my.cnf
文件没有UTF-8
编码。您可以使用od
命令检查并查看此编码中是否存在某些内容。原因 2
您缺少
[mysqld]
文件顶部的指令。如我所见,您没有该选项,因此只需添加它并重试。通常运行你的 MySQL 只听
127.0.0.1
是一个很好的做法,因为它只允许来自你本地机器的连接。其余的安全选项基于您授予数据库、表等的权限。InnoDB 允许压缩。有关详细信息,请参阅参考手册。