mysqldump: [ERROR] unknown variable ‘datadir=/var/lib/mysql‘

mysqldump: [ERROR] unknown variable ‘datadir=/var/lib/mysql’

问题描述

在linux环境下操作mysql的时候抛出异常

问题解决

[ERROR] unknown variable ‘datadir=/var/lib/mysql’
这里问题的出现一般是是因为你操作了 /etc/my.cnf 所造成的,比如你想加个什么属性,一不留神加错了位置,本来属于[mysqld] 下的东西变成了其他的模块,
所以说如果你想加入其他什么模块,一定要注意位置,我这里是因为加[mysqldump]模块的时候,没有看到下面的那几行

ps : 原版没有改动过的 /etc/my.cnf 好多注释,下面有两行是没有注释,发现了没,猛男流泪!

代码

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqldump]
socket=/tmp/mysql.scok
default-character-set=utf8mb4
host=127.0.0.1
user=root
password='abc123'

[mysql] # 注意这里mysql,没有的自己写
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
default-time_zone = '+8:00'

# 这里的注释是坑爹的东西,我就是因为加到这里了所以datadir=/var/lib/mysql 就不再[mysqld]下面了,就报错了!,所以建议,加模块加到上面吧
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

你可能感兴趣的:(mysql,linux,mysql)