MySQL my.cnf文件 - 找不到前一组的选项

时间:2021-08-25 19:24:32

I'm trying to connect to my DB in Ubuntu remotely but I receive error message when trying to mysql -u root -p:

我正在尝试远程连接到Ubuntu中的数据库但是在尝试mysql -u root -p时收到错误消息:

Found option without preceding group in config file: /etc/mysql/my.cnf at line: 1

在配置文件中找到没有前面组的选项:/etc/mysql/my.cnf at line:1

my.cnf looks like:

my.cnf看起来像:

[mysqld]
user        = mysql
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
bind-address        =  0.0.0.0
key_buffer      = 16M
max_allowed_packet  = 16M
thread_stack        = 192K
thread_cache_size       = 8
myisam-recover         = BACKUP
query_cache_limit   = 1M
query_cache_size        = 16M
log_error                = /var/log/mysql/error.log
expire_logs_days    = 10
max_binlog_size         = 100M

[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock

[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

[mysqldump]
quick
quote-names
max_allowed_packet  = 16M

[mysql]

[isamchk]
key_buffer      = 16M

3 个解决方案

#1


24  

Check the charset encoding of the file, make sure that it is in ASCII . Use the 'od' command to see if there is a UTF-8 BOM at the beginning, for example.

检查文件的charset编码,确保它是ASCII格式。例如,使用'od'命令查看开头是否有UTF-8 BOM。

#2


35  

Just add [mysqld] as first line of your /etc/mysql/my.cnf file

只需添加[mysqld]作为/etc/mysql/my.cnf文件的第一行

And then

接着

sudo mysqld stop sudo mysqld start

sudo mysqld stop sudo mysqld start

#3


11  

it is because of letters or digit infront of [mysqld] just check the leeters or digit anything is not required before [mysqld]

这是因为[mysqld]面前的字母或数字只是在[mysqld]之前检查了汇率或数字是不需要的。

it may be something like

它可能是这样的

0[mysqld] then this error will occur

0 [mysqld]然后会发生此错误

#1


24  

Check the charset encoding of the file, make sure that it is in ASCII . Use the 'od' command to see if there is a UTF-8 BOM at the beginning, for example.

检查文件的charset编码,确保它是ASCII格式。例如,使用'od'命令查看开头是否有UTF-8 BOM。

#2


35  

Just add [mysqld] as first line of your /etc/mysql/my.cnf file

只需添加[mysqld]作为/etc/mysql/my.cnf文件的第一行

And then

接着

sudo mysqld stop sudo mysqld start

sudo mysqld stop sudo mysqld start

#3


11  

it is because of letters or digit infront of [mysqld] just check the leeters or digit anything is not required before [mysqld]

这是因为[mysqld]面前的字母或数字只是在[mysqld]之前检查了汇率或数字是不需要的。

it may be something like

它可能是这样的

0[mysqld] then this error will occur

0 [mysqld]然后会发生此错误