MySQL not picking up symlinked cnf changes in 5.7.13 on Ubuntu 16.04 - mysql

EDIT: I may have found what might be part of the issue, further edit at the bottom.
I've got a new server setup running mysql everything seems to be okay. Except whenever I use show variables the configuration settings I can see in my .cnf file are not being shown and what appear to be general defaults are being shown. So it would appear while I can use mysql just fine, the settings are all just the defaults.
I am trying to figure out why my .cnf is not being used. I have taken a number of steps to check that it is definitely being loaded and these are laid out below. Once I am sure it is being loaded I am at a loss as to how to explain why my settings aren't being used. Any help would be greatly appreciated.
The location of my cnf file is this:
/etc/mysql/mysql.conf.d/mysqld.cnf
I have attempted to verify that this is what is being used by the following:
sudo /usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
/etc/my.cnf does not exist
/etc/mysql/my.cnf is a symlink to /etc/alternatives/my.cnf
/etc/alternatives/my.cnf is a symlink to /etc/mysql/mysql.cnf
/etc/mysql/mysql.cnf contains:
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
etc/mysql/conf.d/ is a directory that contains:
mysql.cnf
mysqldump.cnf
mysql.cnf is empty so presumably isn’t doing anything
/etc/mysql/mysql.conf.d/ is a directory that contains:
mysqld.cnf
mysqld.cnf.dpkg-new
mysqld_safe_syslog.cnf
mysqld.cnf is a symlink to /home/{my_username}/conf/mysqld.cnf
/home/{my_username}/conf/mysqld.cnf is my conf file which I expect it to be using.
So I cannot see the problem it looks like it should be using my config.
In a second attempt to verify that this .cnf is being used I used strace mysql. My file was listed and opened along with the other paths I just listed above.
stat("/etc/mysql/mysql.conf.d/mysqld.cnf", {st_mode=S_IFREG|0664, st_size=2262, ...}) = 0
open("/etc/mysql/mysql.conf.d/mysqld.cnf", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0664, st_size=2262, ...}) = 0
read(4, "# Generated by Percona Configura"..., 4096) = 2262
read(4, "", 4096) = 0
close(4) = 0 close(4)
Again it looks like it should be using the .cnf file.
Can anyone offer any insight into why it's not?
EDIT: I've just done a strace mysqld instead of strace mysql and I get a permission error on my .cnf file. This could be the problem. But I don't understand enough about the difference between mysql and mysqld can anyone explain?
stat("/etc/mysql/mysql.conf.d/mysqld.cnf", {st_mode=S_IFREG|0664, st_size=3218, ...}) = 0
open("/etc/mysql/mysql.conf.d/mysqld.cnf", O_RDONLY) = -1 EACCES (Permission denied)

This was caused and resolved by apparmor
Ubuntu comes with something called AppArmor, a kernel-integrated
application security system that controls how applications can access
the file system. Source: Oracle Article
If you put the .cnf in a custom location, you need to give mysql permissions to access that directory. In my case I needed to edit this /etc/apparmor.d/local/usr.sbin.mysqld with the following:
/home/{my_username}/conf/mysqld.cnf r
You could also use:
/home/{my_username}/conf/* r
To give it access to the whole directory.

Related

MariaDB configuration changes don't take effect

The server is working on CentOS 8, I'm trying to configure MariaDB by making alterations to /etc/my.cnf but then when I restart DB by doing sudo systemctl restart mariadb, the server does restart but no configuration changes get applied.
mysql > SHOW VARIABLES;
It outputs the same values. I tried to comment out the including directive #!includedir /etc/my.cnf.d and to add settings to [mysqld] and [mariadb] sections.
mysql --verbose --help says:
Default options are read from the following files in the given order:
/etc/my.cnf ~/.my.cnf.
The following groups are read: mysql client client-server client-mariadb
Check whether mysql uses the config file debugging it with strace:
sudo strace mysql
In the strace output, look for lines like:
openat(AT_FDCWD, "/etc/my.cnf", O_RDONLY|O_CLOEXEC) = ...
Make sure openat doesn't return -1. In that case check whether the file exists or mysql has enough permissions to read the file.
When adding additional configuration files, make sure that they are not writable by 'other'. Otherwise you'll have a message on mysql startup like:
Warning: World-writable config file '/etc/mysql/conf.d/myproject.cnf' is ignored
and the configuration does not get applied.

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.

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

my.cnf changing datadir, 2days and still no luck

Hi i have been trying this for hours upon hours, this forum is my last resort
sfter googling hundreds of pages.
PROBLEM:
Sorry for the length but i am supplying in detail of what i have tried
I have set up mysql and its working fine, i now need to change the data-storage to point at my External HD.
With mac osx there is no default my.cnf so i copied
my-huge.cnf from /usr/local/mysql-5.1.53-osx10.6-x86/support-files, now if it makes any odds i also have a 'mysql' folder in local also.
when i place and rename my-huge.cnf into /etc
i renamed it to my.cnf like instructed,
it works as normal if i dont add a datadir field which looks like this
datadir= /Volumes/Elements/database,
i have also copied my old data to my new location using
sudo cp -R -p /var/lib/mysql /Volumes/Elements/database
Everything workds fine unless i add the field datadir = /Volumes/Elements/database
to the my.cnf file, if i do i get the error
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
my.cnf file looks like the following
Macintosh-100:support-files seanf$ cd /etc
Macintosh-100:etc seanf$ sudo nano my.cnf
Password:
Macintosh-100:etc seanf$ nano my.cnf
Macintosh-100:etc seanf$ my.cnf > /Desktop/blah.txt
-bash: /Desktop/blah.txt: No such file or directory
Macintosh-100:etc seanf$ my.cnf < /Desktop/blah.txt
-bash: /Desktop/blah.txt: No such file or directory
Macintosh-100:etc seanf$ nano my.cnf
GNU nano 2.0.6 File: my.cnf
# Example MySQL config file for very large systems.
#
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /usr/local/mysql/data) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]l
datadir = /Volumes/Elements/database
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer_size = 384M
etc....
I hope someone can shed light on this, i have an assignment due and have spent 2 days trying to get this working on my external
Also even when mysql is working and i type mysqld i get errors if this is an issue?
Macintosh-100:lib s$ mysqld
101201 13:31:13 [Warning] '--skip-locking' is deprecated and will be removed in a future >release. Please use '--skip-external-locking' instead.
101201 13:31:13 [Warning] Can't create test file /usr/local/mysql-5.1.53-osx10.6-x86/data>/Macintosh-100.lower-test
101201 13:31:13 [Warning] Can't create test file /usr/local/mysql-5.1.53-osx10.6-x86/data>/Macintosh-100.lower-test
mysqld: Can't change dir to '/usr/local/mysql-5.1.53-osx10.6-x86/data/' (Errcode: 13)
101201 13:31:13 [ERROR] Aborting
101201 13:31:13 [Note] mysqld: Shutdown complete
Macintosh-100:lib s$
Thanks for your time i hope an expert can answer this
Though I haven't played with datadir property but I've changed data storage location to the external HD by mounting default location to it as follows:
Backup your current data directory
Delete everything from your data directory
Mount it to your external HD (mount /var/lib/mysql/data /dev/XXX)
I've done it at Ubuntu Server. When changing InnoDB specific directories I've noticed that one have to be careful with rights (apparmord in case of ubuntu). When mysql cannot perform some filesystem operation I find its error messages very misleading. Sometimes it is really helpful to study it's error.log (/var/log/mysql/error.log in my case).
Hope this helps you to resolve your issue ASAP.
Use:
rsync -Pa /var/lib/mysql /Volumes/Elements/database
instead of:
cp -R -p /var/lib/mysql /Volumes/Elements/database
"rsync -a" can keep some permissions important for mysql.

Does MySQL included with MAMP not include a config file?

I can't seem to find the my.cnf or other config file for the MySQL that comes with MAMP. Does it not include one?
The MySQL server of MAMP (not PRO) will be started without any my.cnf file. But you can create your own my.cnf file.
Stop servers
Create a my.cnf file in /Applications/MAMP/conf/
Add your content in to my.cnf
Save my.cnf
Start servers
You do not have to put a complete configuration in the my.cnf file. You can just add parts of a configuration ... for example:
[mysqld]
max_allowed_packet = 64M
Some standard my.cnf variants can be found at /Applications/MAMP/Library/support-files/
Invoking mysqld --verbose --help | less on the MAMP mysqld binary reports:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /Applications/MAMP/conf/my.cnf ~/.my.cnf
Copy one of the variants in /Applications/MAMP/Library/support-files/ to one of the locations in mysqld's search order above, and you should be good to go after restarting the daemon.
Since MAMP server generates my.cnf dynamically on MAMP server startup, it's best to use the following steps to add or edit the MySQL configuration:
Stop MAMP server
Goto Files > Edit Template > MySQL
Make the necessary changes and save
Restart MAMP
I tried this on MAMP PRO 3.5.
For MAMP 3.5 on Mac El Capitan, only this worked for me:
Stop servers
Create a my.cnf file in /Applications/MAMP/Library/
Add your content into my.cnf like
[mysqld]
max_allowed_packet = 64M
Save my.cnf
Start servers
Not required to change ownership of file, it should work. Verify by running SHOW VARIABLES in phpmyadmin and look for your changed setting.
No, it doesn't come with the my.cnf file
I found that MAMP PRO will create a my.cnf by default on startup under the MAMP/tmp directory if a ~/my.cnf is not provided ... grepping ps aux you may find the default location under /Applications/MAMP/tmp/my.cnf ...
ps aux | grep mysql
Which provided the following...
root 284 0.0 0.1 2435544 532 ?? Ss 12:00AM 0:00.06 /bin/sh /Applications/MAMP/Library/bin/mysqld_safe
--defaults-file=/Applications/MAMP/tmp/mysql/my.cnf
--port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock
--user=mysql --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid
--log-error=/Applications/MAMP/logs/mysql_error_log.err
--tmpdir=/Applications/MAMP/tmp/mysql/tmpdir
--datadir=/Library/Application Support/appsolute/MAMP PRO/db/mysql