I have written a line in nano /etc/my.cnf file and how I'm not able to remove it - mysql

I have added secure-file-priv = "" to my nano /etc/my.cnf file for mysql and now I'm not able to remove it.When I remove that line and try to save it, it's asking me to write to a file and the changes are not saved
I tried to uninstall and install mySQL but due to this the server is not able to start.
Error Messages:
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1.
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Starting MySQL
.my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1.
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1.
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Is there any way I can fix this error, I tried a lot but couldn't find any solution

"errors when saving" are often linked to access rights issues.
run ls -l /etc/my.cnf to confirm that this file is owned by root.
in the vast majority of cases, system wide configuration files are owned by root. To edit a root file, you should do it with root privileges, e.g :
sudo nano /etc/my.cnf
(that's probably how you were able to add the config parameter in the first place)

Related

Installation error mysql 5.7 on ubuntu 20.04

When I try to execute the following command to install mysql 5.7 in ubuntu 20.04 machine the following error appears. I am following the documentation in here https://computingforgeeks.com/how-to-install-mysql-on-ubuntu-focal/ when installing the mysql.
sudo apt install -f mysql-client=5.7* mysql-community-server=5.7* mysql-server=5.7*
Setting up mysql-common (5.8+1.0.5ubuntu2) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Setting up libtinfo5:amd64 (6.2-0ubuntu2) ...
Setting up mysql-community-client (5.7.35-1ubuntu18.04) ...
Setting up mysql-client (5.7.35-1ubuntu18.04) ...
Setting up mysql-community-server (5.7.35-1ubuntu18.04) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: [ERROR] Found option without preceding group in config file /etc/my.cnf at line 1!
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Setting up mysql-server (5.7.35-1ubuntu18.04) ...
Processing triggers for systemd (245.4-4ubuntu3.11) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
And the /etc/mysql/my.cnf file has only the following lines, others are commented and it is the default file.
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
When I check the /etc/mysql/conf.d/ directory, following files were there.
mysql.cnf
[mysql]
mysqldump.cnf
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
When I check the /etc/mysql/mysql.conf.d/ directory, following file were there.
mysqld.cnf
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
log-error = /var/log/mysql/error.log
# By default we only accept connections from localhost
bind-address = 127.0.0.1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
And the /etc/my.cnf file looks like below.
basedir=/var/lib/mariadb/mysql
datadir=/var/lib/mariadb
user=mysql
sudo su
apt install mysql-server mysql-client
it will work

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

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.

Can´t connect to MySQL server on '127.0.0.1' (61)

Im trying to connet to 127.0.0.1 using Sequel Pro:
Name: test
Host: 127.0.0.1
user: root
But it appears an error:
Connection failed, Can´t connect to MySQL server on '127.0.0.1' (61)
If I execute the command:
mysql.server start
It appears the error:
ERROR! The server quit without updating PID file (/usr/local/var/mysql/John.local.pid).
Do you know how to fix?
Full error:
my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 - No such file or directory)
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Starting MySQL
.my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 - No such file or directory)
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
my_print_defaults: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 - No such file or directory)
my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
ERROR! The server quit without updating PID file (/usr/local/var/mysql/John.local.pid).
You could try with sudo chown -R _mysql:_mysql /usr/local/var/mysql, maybe it is only
Install homebrew, https://brew.sh/ or write following command
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
To make or change directory please run following command
mkdir /usr/local/etc/my.cnf.d
Link mysql
brew link mysql
Restart MySQL
brew services restart mysql
If that process not work, please backup your database and reinstall MySQL

MySQL can't write to temp directory

I tried everything and whenever i try to start mysql i get this error
140526 18:21:36 InnoDB: Using Linux native AIO
^G/usr/sbin/mysqld: Can't create/write to file '/mysql/ibAlmthH' (Errcode: 13)
I even tried to chnage tmp dir in my.cnf with full write permissions but i still get that error
I tried this post
https://stackoverflow.com/a/16178696
But still same error
what should i do
Refer this, from the stackoverflow question number-2783313 may it help:
Recent Ubuntu Server Editions (such as 10.04) ship with AppArmor and MySQL's profile might be in enforcing mode by default. You can check this by executing sudo aa-status like so:
# sudo aa-status
5 profiles are loaded.
5 profiles are in enforce mode.
/usr/lib/connman/scripts/dhclient-script
/sbin/dhclient3
/usr/sbin/tcpdump
/usr/lib/NetworkManager/nm-dhcp-client.action
/usr/sbin/mysqld
0 profiles are in complain mode.
1 processes have profiles defined.
1 processes are in enforce mode :
/usr/sbin/mysqld (1089)
0 processes are in complain mode.
If mysqld is included in enforce mode, then it is the one probably denying the write. Entries would also be written in /var/log/messages when AppArmor blocks the writes/accesses. What you can do is edit /etc/apparmor.d/usr.sbin.mysqld and add /data/ and /data/* near the bottom like so:
...
/usr/sbin/mysqld {
...
/var/log/mysql/ r,
/var/log/mysql/* rw,
/var/run/mysqld/mysqld.pid w,
/var/run/mysqld/mysqld.sock w,
/data/ r,
/data/* rw,
}
And then make AppArmor reload the profiles.
# sudo /etc/init.d/apparmor reload
WARNING: the change above will allow MySQL to read and write to the /data directory. We hope you've already considered the security implications of this.
Try to run this command manually:
touch /mysql/ibAlmthH
If it failed to create it, you then have a filesystem problem, e.g. read-only filesystem,
So you need to fix the filesystem problem first,
Also check the available disk space on this directory, may be there is no space.
Change directory permission to read, write and execute..
Chmod 777 /directory_path

Can't create/write to file '/var/lib/mysql/aria_log_control'

Something is wrong. I stopped MaridaDB, moved /var/lib/mysql to a different place, then replaced the old mysql with a softlink
cd /var/lib
ln -s /data/mysql .
Then I added
chown -R mysql:mysql mysql
and then I went to /data and did the same (Note: this relocation works fine in regular mysql). But in MariaDB
ERROR] mysqld: Can't create/write to file
'/var/lib/mysql/aria_log_control' (Errcode: 13 "Permission denied")
[ERROR] mysqld: Got error 'Can't create file' when trying to use aria
control file '/var/lib/mysql/aria_log_control' [ERROR] Plugin 'Aria'
init function returned error. [ERROR] Plugin 'Aria' registration as a
STORAGE ENGINE failed.
So what can I do to fix this? I tried setting
chmod 777 /var/lib/mysql/aria_log_control
but to no avail.
In my case the problem was that while directory mysql and files within were owned by user mysql, the path has a directory that lacked x bit for the users that are not in the correct group. In other words, user could not move to the target directory because one of the directories in the path did not allow it.
In My case this happened after a change which required OS restart, turned out that SELINUX was in ENFORCE mode and was not allowing MySQL to access the files, used below command to resolve:
sudo getenforce
sudo setenforce 0