Home  >  Article  >  Database  >  \"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?\"

DDD
DDDOriginal
2024-10-26 17:04:30660browse

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.

The above is the detailed content of \"Found Option without Preceding Group in my.cnf: Why and How to Fix it?\". For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn