Home > Database > Mysql Tutorial > body text

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

DDD
Release: 2024-10-26 17:04:30
Original
659 people have browsed it

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
Copy after login

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)
Copy after login

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

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

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
Copy after login

CentOS/Red Hat

sudo service mysqld stop
sudo service mysqld start
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!