"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > \"Found Option without Preceding Group in my.cnf: Why and How to Fix it?\"

\"Found Option without Preceding Group in my.cnf: Why and How to Fix it?\"

Published on 2024-11-09
Browse:169

\

Found Option without Preceding Group in my.cnf File

When attempting to connect to a MySQL database remotely using the command mysql -u root -p, users may encounter the error message:

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

Cause

This error occurs when the my.cnf configuration file is missing the [mysqld] header. The my.cnf file contains configuration settings for MySQL, and each section must be enclosed within square brackets ([]) with the corresponding section name.

Solution

To resolve this issue, add the [mysqld] header as the first line in the /etc/mysql/my.cnf file.

[mysqld]
... (remaining configuration settings)

For example, if you wish to set the default time zone:

[mysqld]
default-time-zone = " 08:00"
... (remaining configuration settings)

Restart MySQL

After making the necessary changes to the my.cnf file, restart the MySQL service to apply the new settings.

Ubuntu/Debian

sudo mysqld stop
sudo mysqld start

CentOS/Red Hat

sudo service mysqld stop
sudo service mysqld start

Once the MySQL service has been restarted, you should be able to establish a remote connection without encountering the error message.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3