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

I haven't found anything online that's helped me address this error. I had to uninstall mysql, and I used this guide to uninstall. Then I reinstalled it. I got this error:
mysqld: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1.
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
So I uninstalled again, and attempted to uninstall the my.cnf file as well. After reinstalling a second time, I opened my.cnf and my.cnf.default files and [mysqld] is at the very top, with nothing (no comments or space) above it. I also checked to make sure that the files are in UTF-8. I still get this error when running brew postinstall mysql.
Here's what my.cnf file looks like, I moved the comments to the bottom to see if it would fix it:
[mysqld]
bind-address = 127.0.0.1
mysqlx-bind-address = 127.0.0.1
# Default Homebrew MySQL server config
# Only allow connections from localhost
If anyone has any insight that would be greatly appreciated. I'm running MacOS Big Sur.

Related

For homebrew mysql installs, how to fix mysql.sock path?

I am on macOS 10.12.3. Installed and running MySQL through Homebrew. Whenever i try to start MySQL with brew services start mysql or sudo mysql.server start command on terminal, it starts. Following is my my.cnf file residing into /etc/my.cnf
[mysqld]
user=mysql
basedir=/usr/local/Cellar/mysql/5.7.17
datadir=/usr/local/var/mysql
port=3306
server_id=1
socket=/tmp/mysql.sock
[client]
user=mysql
basedir=/usr/local/Cellar/mysql/5.7.17
datadir=/usr/local/var/mysql
port=3306
server_id=1
socket=/tmp/mysql.sock
Then i try to connect to MySQL using Perfect-MySQL following the instructions there. But failed to locate and connect to socket file. Got the following error,
[ERR] MySQL connection error: Can't connect to local MySQL server through socket '' (2)
[ERR] Error msg: error("MySQL server has gone away")
Clearly it failed to identify socket file path which should be /tmp/mysql.sock. But after running mysql server i found mysql.sock.lock.lock file into /tmp/ folder, there were no mysql.sock file.
Then i changed the my.cnf file with socket=/tmp/mysql.sock.lock.lock . but same result.
I have no other mysql client/service installed and tried freshly reinstalling with homebrew several times. Same result everytime.
I have tried with a lot of other options but no luck. CLearly i am missing something. Can someone please shade some light on it ?
How and from where i can set mysql.sock path ?

mysqld ignoring my.cnf (mysql 5.6 on Ubuntu 16.04 Server)

I installed mysql 5.6 on Ubuntu Server 16.04 using this method: https://askubuntu.com/questions/762384/install-mysql-5-6-on-ubuntu-16-04
But i'm having trouble getting mysqld to read /etc/mysql/my.cnf
Specifically i'm trying to set it up for an Atlassian Confluence installation where I have to add in these settings:
[mysqld]
character-set-server=utf8
collation-server=utf8_bin
default-storage-engine=INNODB
max_allowed_packet=256M
innodb_log_file_size=2G
I've checked mysqld --help --verbose and it has the my.cnf in its path. Here's the relevant output:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf The following
groups are read: mysqld server mysqld-5.6
I know that mysql is reading the file because if I change [mysqld] to [mysql] the arguments are correctly printed when I run mysql --print-defaults also if I put a wrong line in the file mysql will fail to start and tell me where the syntax error is. However mysqld does not report any arguments for mysqld --print-defaults or tell me about syntax errors in the file.
What else can I try?
Solved:
my.cnf was a symbolic link. I deleted it and made it an actual file. Now mysqld --show-defaults is working! So apparently mysql will follow the symlink but mysqld will not. Good to know.
my.cnf was a symbolic link. I deleted it and made it an actual file. Now mysqld --show-defaults is working. So apparently mysql will follow the symlink but mysqld will not.
For mysqld as I know only hard links works. Or maybe you just had wrong permission, on original my.cnf file to which you put symbolic link.

ERROR! The server quit without updating PID file XAMPP

I know there are a lot of similar problems, but I have to post this because I am not finding a solution yet. Below is what happens when I try to run mysql. Not using homebrew here! I originally fixed the problem by killing the process ID for mysqld, but since I shut my computer down and relocated, then restarted, I am getting this error again. It seems to be the same except the difference with this error is the local.pid part. This was not in my original error message and wandering how to fix this?
Original error fixed by killing the process ID:
ERROR! The server quit without updating PID file (/Applications/XAMPP/xamppfiles/var/mysql/genevieve-ouellons-macbook-pro.pid)
The new error after shutdown, relocate and trying to start:
genevieve-ouellons-macbook-pro:bin genevieveouellon$ cd /Applications/XAMPP/xamppfiles/bin
genevieve-ouellons-macbook-pro:bin genevieveouellon$ ./mysql.server start
Warning: World-writable config file '/Applications/XAMPP/xamppfiles/etc/my.cnf' is ignored
Starting MySQL
. ERROR! The server quit without updating PID file (/Applications/XAMPP/xamppfiles/var/mysql/genevieve-ouellons-macbook-pro.local.pid).
Anyone have this problem?
Thanks
It worked by using these two commands:
cd /Applications/XAMPP/xamppfiles/bin
sudo ./mysql.server start
Using sudo is the keyword that made the difference this time around.
sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
Above command worked in my case, only if the port is empty..
If this results error, restart server/mac and try the above command.. Hope this helps for someone..
Might've been deleted when you manually restarted mysql or renamed your machine. Not sure about XAMPP but when using mysql on OSX this is my go-to..
cd into /Applications/XAMPP/xamppfiles/var/mysql/
rm -rf *.local.err (deletes file)
touch YOURUSERNAME.local.pid (generates *.local.pid file the error thrown was complaining about)
cd back into your project and restart mysql using mysql.server start
Finally solved this issue... (3 days later)
Open up YOURUSERNAME.local.err in /Applications/XAMPP/xamppfiles/var/mysql/ with a text editor.
I had "InnoDB: Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files"
Then follow instructions on http://dev.mysql.com/doc/refman/5.6/en/forcing-innodb-recovery.html as it states in the log file
Add innodb_force_recovery = 2 after line: [mysqld] to your my.cnf located in /XAMPP/xamppfiles/etc/
Then sudo /Applications/XAMPP/xamppfiles/bin/mysql.server start
Give it a minute and it should repair itself
Comment out with #innodb_foce_recovery = 2 in my.cnf
Unfortunately none of possible solutions did not helped me.
Still the Mysql was not able to start and in terminal I saw only /Applications/XAMPP/xamppfiles/var/mysql/: "ERROR!" without any further info
I simply reinstalled XAMPP again - worked

try to change bin log directory: mysql-bin.index not found (Errcode: 13)

MySQL 5.1.54
Ubuntu 11.04
I'am try to change bin log directory in my.conf as:
[mysqld]
log_bin=/home/developer/logs/mysql/mysql-bin.log
After this changes MySQL server can't start with error:
/usr/sbin/mysqld: File '/home/developer/logs/mysql/mysql-bin.index'
not found (Errcode: 13)
111005 12:47:58 [ERROR] Aborting
Permission for directory /home/developer/logs/mysql/ is 0777
What's going on?
As usual, the solution was simple but not obvious: it needed to edit apparmor settings
I just added to /etc/apparmor.d/usr.sbin.mysqld a new string with path to target directory: /home/developer/logs/* rw
It works!
/usr/sbin/mysqld: File '/usr/binlogs/mysql-bin.index' not found
(Errcode: 13)
It worked for me with:
chown -R mysql:mysql /usr/binlogs/
Just as an FYI for anyone who runs into a similar problem, the solution is basically the same, but the cause of the problem isn't obvious.
After upgrading Debian wheezy, mysql failed to start.
Somehow, I have no idea how, permissions on some of the files in /var/lib/mysql were not owned by the mysql user, thus preventing the server from firing up.
A chown -R mysql.mysql /var/lib/mysql fixed it.
I didn't do anything to mess up mysql, it was a standard:
apt-get update
apt-get upgrade
Something got hinky during the Debian upgrade and manual intervention was needed.
Selinux might enforce the rule that MySQL database files have to live in /var/lib/mysql and not anywhere else. Try turning off selinux (selinux=0 on kernel boot command line) if you moved mysql to another directory.
Option 1:
service mysqld stop
Copy the log files including the .index file to new location.
cp mysql-bin.log* /path/to/binlogs
cp mysql-bin.index /path/to/binlogs
Do Changes in the /etc/my.cnf file.
[mysqld]
log-bin=/path/to/newdirecory/mysql-bin
log-bin-index=/path/to/newdirectory/mysql-bin.index
service mysqld start
Option 2:
Use this utiltiy to relocate binary logs:
mysqlbinlogmove --binlog-dir=/server/data /new/binlog_dir
You need to give user permissions to the directory as follows:
chown -R mysql:mysql /home/developer/logs/mysql/
Does your user have access to all upper directories? In special, the /home/developer/ directory? Try to log in with the mysql server account and touch the log file.
mysqld: File '/data/log/mysql/mysql-bin.index' not found (Errcode: 2
- No such file or directory)
I was really stuck in the middle of my MySQL Master - Slave setup. Finally the above was a permission issue, adding the below command solved my issue.
chown -R mysql:mysql /data/log/mysql/
I had a similar problem when I was trying to change the datadir variable during a fresh install. The solution in my case was to run the first time start up with log-bin disabled. After that I was able to enable it again using the new path ...
Your config is wrong:
log_bin=/home/developer/logs/mysql/mysql-bin.log
You would use instead
log-bin=/home/developer/logs/mysql/mysql-bin.log
During replication configuration in "my.cnf" file needs to mention
server-id=1
log_bin=/var/log/mysql/mysql-bin.log
you can make your own directory and give permission.
create directory "mysql" in /var/log/
chmod 777 mysql
this is applicable with MySQL version 5.7
You can also comment the line in my.cnf file which is defining the log location, so mysql will consider its default path and will start properly.
log-bin = /var/log/mysql/mysql-bin.log -> #log-bin = /var/log/mysql/mysql-bin.log.
This will be helpful if you are not concerned much about logs.
As documentation in mysql say https://dev.mysql.com/doc/refman/5.7/en/replication-options-binary-log.html#sysvar_log_bin
The variable is log_bin and not log-bin at least in version 5.7

MySql server startup error 'Manager of pid-file quit without updating file.'

I read in some forums that doing a giving a /bin/sh before the /etc/init.d/mysql start would solve the problem and it did. but we don't want to start it every time like that...what is the solution? I have installed the following packages from http://www.mysql.com/downloads/mysql/#downloads, I am using CentOS 5.:
MySQL-community-debuginfo-5.1.50-1.rhel5.x86_64.rpm
MySQL-client-community-5.1.50-1.rhel5.x86_64.rpm
MySQL-server-5.1.50-1.glibc23.x86_64.rpm
MySQL-devel-5.1.50-1.glibc23.x86_64.rpm
Is there anything missing?
Was your computer recently hard-reset? If mysqld doesn't get a chance to shutdown properly the pid file won't be removed. Have you tried manually removing the pid file?
Reference:
http://bugs.mysql.com/bug.php?id=44492
On my CentOS 5 install the pid file is in: /var/run/mysqld/mysqld.pid
This error could also be caused by incorrect my.cnf settings.
Try renaming the file and starting again:
[centos]# mv /etc/my.cnf /etc/my.cnf-old
[centos]# service mysql start
If it starts then you should check what was changed in the my.cnf settings.
[centos]# diff -bB /etc/my.cnf /etc/my.cnf-old