my.cnf file missing and cannot be found at any directory - mysql

I recently removed mysql 5.1 an installed mysql 5.6 on my CENTOS 6 x86 OS.
When I try to look for the my.cnf file it is missing from these directories:
mysqld --verbose --help | grep -A 1 "Default options"
=
/etc/my.cnf, /etc/mysql/my.cnf, and ~/.my.cnf.
Now I went to my mysql home directory which is /var/lib/mysql to find the .cnf file but all I found was auto.cnf.
Does anyone have any ideas? Could I just download a my.cnf file and place it in one of those directories?

sudo updatedb && locate my.cnf

if you are having trouble with locate
as root: find / -name my.cnf
how did you install mysql? with yum?

I am running Centos 6.5. When I went to install MySQL-server.X86_64 5.6.12-2.el6, it put my.cnf in /usr. /usr/my.cnf ? What the hell is my.cnf doing in /usr ?
I found it using find / -iname my.cnf -print

The location is changed to /mysql.d, and the filename is changed to something like mysqld.cnf. Also, there's a similar question somewhere (maybe duplicate here or there).

Related

Where is my.ini in MacOS Sierra

I installed mysql with homebrew with this guide https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e
Now I need to delete the server variable NO_ZERO_DATE from the mysql configuration but i don't found mysql conf file. Where is located this file?
In MacOS the my.ini file is found as my.cnf, you can look for it in terminal with
> mysql --help
"Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf"
But if you hadn't found the cnf in the locations that help show you, try with the next command
> ls $(brew --prefix mysql)/support-files/my-*
For example, I got this file
/usr/local/opt/mysql/support-files/my-default.cnf
then you need to copy this file to one of your default directories, in my case /etc/my.cnf
> sudo cp /usr/local/opt/mysql/support-files/my-default.cnf /etc/my.cnf
Finally open your cnf file and delete STRICT_TRANS_TABLES from sql_mode
> nano /etc/my.cnf
sql_mode=NO_ENGINE_SUBSTITUTION
Exit with ctrl+x and press S
Don't forget to restart your mysql server
> sudo mysql.server stop
> sudo mysql.server start

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.

For homebrew mysql installs, where's my.cnf?

For homebrew mysql installs, where's my.cnf? Does it install one?
There is no my.cnf by default. As such, MySQL starts with all of the default settings. If you want to create your own my.cnf to override any defaults, place it at /etc/my.cnf.
Also, you can run mysql --help and look through it for the conf locations listed.
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: mysql client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit.
--no-defaults Don't read default options from any option file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
As you can see, there are also some options for bypassing the conf files, or specifying other files to read when you invoke mysql on the command line.
The homebrew mysql contains sample configuration files in the installation's support-files folder.
ls $(brew --prefix mysql)/support-files/my-*
If you need to change the default settings you can use one of these as a starting point.
cp $(brew --prefix mysql)/support-files/my-default.cnf /usr/local/etc/my.cnf
As #rednaw points out, a homebrew install of MySQL will most likely be in /usr/local so the my.cnf file should not be added to the system /etc folder, so I’ve changed the command to copy the file into /usr/local/etc.
If you are using MariaDB rather than MySQL use the following:
cp $(brew --prefix mariadb)/support-files/my-small.cnf /usr/local/etc/my.cnf
One way to find out:
sudo /usr/libexec/locate.updatedb
# wait a few minutes for it to finish
locate my.cnf
in my system it was
nano /usr/local/etc/my.cnf.default
as template and
nano /usr/local/etc/my.cnf
as working.
Nothing really helped me - I could not overwrite settings in a /etc/my.cnf file.
So I searched like John suggested https://stackoverflow.com/a/7974114/717251
sudo /usr/libexec/locate.updatedb
# wait a few minutes for it to finish
locate my.cnf
It found another my.cnf in
/usr/local/Cellar/mysql/5.6.21/my.cnf
changing this file worked for me! Don't forget to restart the launch Agent:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Update:
If you have a fairly recent installation of homebrew you should use the brew services commands to restart mysql (use your installed homebrew mysql version, i.e. mysql or mysql#5.7):
brew services stop mysql
brew services start mysql
Since mysql --help shows a list of files, I find it useful to pipe the result to ls to see which of them exist:
$ mysql --help | grep /my.cnf | xargs ls
ls: /etc/my.cnf: No such file or directory
ls: /etc/mysql/my.cnf: No such file or directory
ls: ~/.my.cnf: No such file or directory
/usr/local/etc/my.cnf
For my (Homebrew installed) MySQL 5.7, it seems the files is on /usr/local/etc/my.cnf.
Add another answer cause
The accepted anwser is right. Since we're talking about Homebrew installed mysql, not MySQL installed manually, there's more direct way to find the conf.
The former answers may be a little outdated, Homebrew on M1 Mac is stored in a different location
Conf
The my.cnf is copied by Homebrew to following places during installation
/usr/local/etc/my.cnf for x86 Mac
/opt/homebrew/etc/my.cnf for M1 Mac
Homebrew chooses /usr/local, or /opt/homebrew to store packages, so the default conf files are not stored in /etc/ but /usr/local/etc or /opt/homebrew/etc.
In fact, homebrew changed the -DSYSCONFDIR= (default conf location) flag during compiling mysql from source.
Start the Service
A short answer: run brew info mysql and check the tips.
The recommended way is brew services start mysql, which uses the launchd to manage services. (launchd is deemed a systemd alternative on macOS)
For anyone wanna start it manually, mysql.start without any option is enough to start the service. (mysql.start is a script provided by mysql to help start the service)
On your shell type my_print_defaults --help
At the bottom of the result, you should be able to see the file from which the server reads the configurations. It prints something like this:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
Server version: 8.0.19 Homebrew. macOS Catalina 10.15.5 and installed MySQL via Homebrew. Found this file here:
/usr/local/etc/my.cnf
This solution helped :)
You can find where the my.cnf file has been provided by the specific package, e.g.
brew list mysql # or: mariadb
In addition to verify if that file is read, you can run:
sudo fs_usage | grep my.cnf
which will show you filesystem activity in real-time related to that file.
I believe the answer is no. Installing one in ~/.my.cnf or /usr/local/etc seems to be the preferred solution.
run
sudo find / -name my.cnf
Usually the first result is the correct one.
Should be in
/usr/local/etc/
In case of Homebrew, mysql would also look for my.cnf in it's Cellar directory, for example:
/usr/local/Cellar/mysql/5.7.21/my.cnf
For the case one prefers to keep the config close to the binaries - create my.cnf here if it's missing.
Restart mysql after change:
brew services restart mysql
If you are using mac m1 (Apple silicon), the my.cnf is located at
/opt/homebrew/etc/my.cnf
and can also be found by mysql --help
I have installed MySQL 5.7 using Homebrew
my.cnf file is located in "/opt/homebrew/etc/my.cnf"
For MacOS (High Sierra), MySQL that has been installed with home brew.
Increasing the global variables from mysql environment was not successful. So in that case creating of ~/.my.cnf is the safest option. Adding variables with [mysqld] will include the changes (Note: if you change with [mysql] , the change might not work).
<~/.my.cnf> [mysqld] connect_timeout = 43200 max_allowed_packet =
2048M net_buffer_length = 512M
Restart the mysql server. and check the variables.
y
sql> SELECT ##max_allowed_packet;
+----------------------+ | ##max_allowed_packet |
+----------------------+ | 1073741824 |
+----------------------+
1 row in set (0.00 sec)
$ps aux | grep mysqld
/usr/local/opt/mysql/bin/mysqld --basedir=/usr/local/opt/mysql --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/opt/mysql/lib/plugin
Drop your my.cf file to /usr/local/opt/mysql
brew services restart mysql

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

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