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
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.
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)
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.
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