Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL my.cnf file - Found option without preceding group

Tags:

mysql

my.cnf

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

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

my.cnf looks like:

[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 
like image 1000
Afra Avatar asked Nov 05 '11 12:11

Afra


Video Answer


2 Answers

Missing config header

Just add [mysqld] as first line in the /etc/mysql/my.cnf file.

Example

[mysqld] default-time-zone = "+08:00" 

Afterwards, remember to restart your MySQL Service.

sudo mysqld stop sudo mysqld start 
like image 101
vmishra Avatar answered Sep 21 '22 22:09

vmishra


Charset encoding

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.

like image 31
aleroot Avatar answered Sep 18 '22 22:09

aleroot