mysql config variable: where in the world is my.ini? - mysql

I am trying to change one of the mysql variables.
[mysqld]
ft_min_word_len=2
On the external server, I was able to change this in my.cnf. However, I cannot for the life of me find this file on my computer. I also cannot find my.ini (I am on windows). I can find my-huge.ini and various other sizes.
QUESTIONS
Might it be called something else?
Do I have to make it? Or, is there a way to change this option without opening the file?
Since ft_min_word_len already has a value, it must be SOMEWHERE!
I tried
mysqld --help
but it does not tell me anything really. I tried:
mysqld --help --verbose
It says very much and whatever is at the start, I cannot see. It won't let me print to any files: "access is denied"
Edit: I looked for it using
dir /s my.ini

I have a little surprise for you. You said you found my-huge.ini. The folder where my-huge.ini resides is the folder my.ini should be. If my.ini is not in the same folder, THEN my.ini SIMPLY DOES NOT EXIST. Consequently, mysqld.exe is running on pure defaults for all configuration settings.
Whenever MySQL was installed as a service, there was no my.ini created. Over the years, I have noticed that after an MSI installation of MySQL, the file mysqld.exe (which is in the bin folder) looks to the parent directory for the my.ini.
Let's say you found my-huge.ini in c:/wamp/bin/mysql/mysqlVERSIONNUMBER
Just create the my.ini in that place as well. Then, restart the mysql service. Open a DOS Window using Run as Administrator and run the following:
C:\> cd c:\wamp\bin\mysql\mysqlVERSIONNUMBER
C:\> echo "[mysqld]" > my.ini
C:\> echo "ft_min_word_len=2" >> my.ini
C:\> net stop mysql
C:\> net start mysql
Give it a Try !!!

Related

Where to find Percona Configuration file?

Recently I have installed Percona 5.7.12 in my linux box but I have not found any configuration file(like my.cnf for mysql) where i can set/modify global variables.
I want to change the values of default system variables like 'sql_mode', password_policy etc.I tried setting values like *SET GLOBAL sql_mode = 'ALLOW_INVALID_DATES';* but after restart of mysqld instance, it seems old default values are retained.How can I set those values permanently so that modified values are retained??? Any help would be appreciated.
According to Percona's install guide, the config file should be located under /etc/my.cnf:
Percona Server stores the data files in /var/lib/mysql/ by default. You can find the configuration file that is used to manage Percona Server in /etc/my.cnf.
If there is no such file in the /etc directory, then you can create it yourself and set any config parameters there. Parameters in the config file are preserved across MySQL system restarts.
It's this file /etc/mysql/conf.d/mysql.cnf in my Percona 5.7 installation.
I can find it by following these steps:
mysqladmin --help
The output contains these lines:
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
The first file (/etc/my.cnf) doesn't exist on my machine.
The second one (/etc/mysql/my.cnf) contains these lines:
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/percona-server.conf.d/
This file /etc/mysql/conf.d/mysql.cnf in the first directory contains the settings I would expect in /etc/my.cnf.
I was facing this same issue. Found that the xtrabackup versions at both the servers were way different (8.0.23 at the source where the backup was taken and 2.4.9 at the destination where I was trying to restore the backup).
As soon as I upgraded the xtrabackup version to 8.0.23 on the destination server, the "prepare" went smoothly without any issues.

How to make sql-mode="NO_ENGINE_SUBSTITUTION" permanent in MySQL my.cnf

UPDATE FIXED 1/18/15
After we recently updated to MySQL 5.6.27 (from the Ubuntu repo), this option now works. So this appears to have been a problem with the previous version of MySQL.
ORIGINAL QUESTION
With a new upgrade to MySQL (5.6.20), updates and inserts fail unless I set sql-mode to NO_ENGINE_SUBSTITUTION.
Thanks to the documentation, I can run the following from mysql terminal and that fixes the problem (temporarily):
SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';
SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION';`
But the next time MySQL restarts, these settings are lost.
So I have tried to make that permanent by editing /etc/mysql/my.cnf (on my standard server running Ubuntu 12.04.5 LTS), and adding the config settings that the documentation says should be added:
[mysqld]
sql-mode="NO_ENGINE_SUBSTITUTION"
Alternative Syntaxes for Testing
Just for testing purposes, I have also tried the following formats (which do not cause errors when restarting MySQL, but they do not affect the setting).
# dash no quotes
sql-mode=NO_ENGINE_SUBSTITUTION
# underscore no quotes
sql_mode=NO_ENGINE_SUBSTITUTION
# underscore and quotes
sql_mode="NO_ENGINE_SUBSTITUTION"
Nothing works. After restart this setting is lost and I have to run the commands manually again from mysql terminal to make saving work again.
Alternative Locations
I know /etc/mysql/my.cnf is being referenced because we have replication defined in this file, and that is working.
There is not another identical setting in this file that is overwriting it.
I get a list of the config files that are being referenced by running this from the command line:
mysqld --help --verbose
I see a line that reads:
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
This is the default location it "looks" for files, it doesn't mean that it actually found a file there, e.g. my server doesn't have /etc/my.cnf, /usr/etc/my.cnf or ~/.my.cnf.
So it looks like my config in /etc/mysql/my.cnf is the only file mysql is referencing, and therefore this setting is not being overwritten.
Logical Conclusion of Testing
Logically then, it seems the syntax is not correct or is being ignored for some other reason. Any other ideas?
Just to add my configuration to the mix, I'm using MySQL 5.7.8 which has the same strict sql_mode rules by default.
I finally figured the following working in my /etc/mysql/my.conf:
[mysqld]
sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
i.e. dash, not underscore and quotes around the value.
I have NO other my.conf files other than /etc/mysql/my.conf
There are some extra config includes being loaded from /etc/mysql/conf.d/ but they are blank.
And that seems to work for me.
Your server may read a different my.cnf than the one you're editing (unless you specified it when starting mysqld).
From the MySQL Certification Study Guide:
The search order includes two general option files, /etc/my.cnf and
$MYSQL_HOME/my.cnf. The second file is used only if the MYSQL_HOME
environment variable is set. Typically, you seet it to the MySQL
installation directory. (The mysqld_safe script attempts to set
MYSQL_HOME if it is not set before starting the server.) The
option file search order also includes ~/.my.cnf (that is the home
directory). This isn't an especially suitable location for server
options. (Normally, you invoke the server as mysql, or as root
with a --user=mysql option. The user-specific file read by the
server would depend on which login account you invoke it from,
possibly leading to inconsistent sets of options being used.)
Another possibility is of course, that your sql-mode option gets overwritten further down in the same file. Multiple options have to be separated by , in the same line.
P.S.: And you need the quotes, IIRC. Now that you've tried it without quotes, I'm pretty sure, you're editing the wrong file, since MySQL doesn't start when there's an error in the option file.
P.P.S.: Had a look at my config files again, there it's
[mysqld]
sql_mode = "NO_ENGINE_SUBSTITUTION"
and it's working.
It should be:
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
instead of
[mysqld]
sql_mode="NO_ENGINE_SUBSTITUTION"
then restart mysqld service.
Woks fine for me on ubuntu 16.04.
path: /etc/mysql/mysql.cnf
and paste that
[mysqld]
#
# * Basic Settings
#
sql_mode = "NO_ENGINE_SUBSTITUTION"
For me it was a permission problem.
enter:
mysqld --verbose --help | grep -A 1 "Default options"
[Warning] World-writable config file '/etc/mysql/my.cnf' is ignored.
So try to execute the following, and then restart the server
chmod 644 '/etc/mysql/my.cnf'
It will give mysql access to read and write to the file.
On Linux Mint 18 the default config file that has the sql-mode option set is located here :
/usr/my.cnf
And relevant line is:
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
So You can set there.
If not sure what config file has such option You can search for it:
$ sudo find / -iname "*my.cnf*"
And get a list:
/var/lib/dpkg/alternatives/my.cnf
/usr/my.cnf
/etc/alternatives/my.cnf
/etc/mysql/my.cnf.fallback
/etc/mysql/my.cnf
My problem was that I had spaces in between the options on 5.7.20. Removing them so the line looked like
[mysqld]
sql-mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
The solution is pretty easy... Searched for it for a while and it turns out that you just have to edit 2 config-files:
/usr/my.cnf
/etc/mysql/my.cnf
in both files you'll have to add:
[mysqld]
...
sql_mode=NO_ENGINE_SUBSTITUTION
At least, that's what's working for 5.6.24-2+deb.sury.org~precise+2
For me both keys for sql-mode worked. Whether I used
# dash no quotes
sql-mode=NO_ENGINE_SUBSTITUTION
or
# underscore no quotes
sql_mode=NO_ENGINE_SUBSTITUTION
in the my.ini file made no difference and both were accepted, as far as I could test it.
What actually made a difference was a missing newline at the end of the my.ini file.
So everyone having problems with this or similar problems with my.ini/my.cnf: Make sure there is a blank line at the end of the file!
Tested using MySQL 5.7.27.
If you're using mariadb, you have to modify the mariadb.cnf file located in /etc/mysql/conf.d/.
I supposed the stuff is the same for any other my-sql based solutions.
I am running WHM 10.2.15-MariaDB. To permanently disable strict mode first find out which configuration file our installation prefers. For that, we need the binary’s location:
$ which mysqld
/usr/sbin/mysqld
Then, we use this path to execute the lookup:
$ /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
We can see that the first favored configuration file is one in the root of the etc folder but that there is a second .cnf file hidden - ~/.my.cnf. Adding the following to the ~/.my.cnf file permanently disabled strict mode for me (needs to be within the mysqld section):
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION
I found that adding the line to /etc/my.cnf had no effect at all apart from sending me crazy.
It was making me crazy also until I realized that the paragraph where the key must be is [mysqld] not [mysql]
So, for 10.3.22-MariaDB-1ubuntu1, my solution is, in /etc/mysql/conf.d/mysql.cnf
[mysqld]
sql_mode = "ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
[Fixed]
Server version: 10.1.38-MariaDB - mariadb.org binary distribution
Go to: C:\xampp\mysql\bin
open my.ini in notepad and find [mysqld] (line number 27) then after this line(line no 28) just type: skip-grant-tables
save the file and then reload the phpmyadmin page.It worked for me.

mysqldump windows unknown option '--no beep'

I am having a problem with the mysqldump command in general (import/export).
I write in windows command window the following:
C:\MySQL\MySQL Server 5.6\bin> mysqldump -u root -p nameofdabase> C:\temp\dumpfile.sql
and i get "mysqldump unknown option --no beep". It doesn't ask me for my password and it doesn't seem to recognize the mysqldump command even though I see it in the bin directory. What am I doing wrong??I have tried everything from changing paths to changing backslashes. Anything I have found online that seems to work keeps giving me the same kind of error.
Any clues will be much appreciated...Thank you all in advance
You probably have a line in my my.ini (or my.cnf) file that says "no-beep". This is an option for the mysql client, but not for mysqldump.
If you want the "no-beep" option for the mysql client only, edit your my.ini file and move it under the file section heading [mysql].
See also mysqldump unknown option no beep
There is a "default" my.ini here: C:\ProgramData\MySQL\MySQL Server 5.7\my.ini.
It contains the no-beep option.
The MySQL Installer has my.ini templates for various versions in C:\ProgramData\MySQL\MySQL Installer for Windows\Manifest\Templates\, for some reason, all of it contains this option.

Installing MySQL Workbench but File /etc/my.cnf doesn't exist

I managed to download the MySQL DMG archive to my OS (mac OS X). It works if I use the command line.
Now, I'm trying to install MySQL Workbench.
I've created MySQL Connection but once I'm testing the host machine settings, I get:
Checking command 'ps xa | grep "/usr/local/mysql.*/bin/[m]ysqld"'
Server detected as running
Check if /etc/my.cnf can be accessed
Operation failed: File /etc/my.cnf doesn't exist
I'm trying to find the file my.cnf and I get:
Didis-MacBook:~ Didi$ find . -type f -name "*my.cnf*"
find: ./perms/newdir: Permission denied
So I tried to create my own "my.cnf" by entering:
cd /usr/local/mysql/support-files/
sudo cp my-huge.cnf /etc/my.cnf
Then it asked for a password. I don't remember setting up a password.
So I typed:
/usr/local/psa/bin/admin --show-password
and get:
-bash: /usr/local/psa/bin/admin: No such file or directory.
I believe my password should be in /etc/passwd but I have no dir "etc" in my system!
I'm running out of ideas, can somebody help me please?
I figured it out:
Went to my terminal and typed:
passwd
Old password was blank
I created a new password (it was THAT simple)
I created a "etc" directory
I checked the files under /usr/local/mysql/support-files/ and saw my cnf file was actually named my-default.cnf and not my-huge.cnf like the developer at the MySQL site.
So I typed: sudo cp my-default.cnf /etc/my.cnf
went back to the Workbench and it FINALLY said:
Testing host machine settings is done.
The MySQL Server installation on OS X does not include a cnf file, so it is normal that you get the warning. Nonetheless you can continue creating the connection without problems (ignore the warning). When you start MySQL Workbench afterwards and try to manage the configuration of the server, you will get another warning, but you can continue and MySQL Workbench creates the cnf file for you. No need to do all that manually.
I met this problem too. I just clicked the continue button until i was at "Review remote management settings" step, and stop here click "change parameters", then continue. At "Path to configuration file" choose the path point to my-default.cnf. Then check path, it works

logging mysql queries wont work

I am running on Ubuntu and I've modified /etc/mysql/my.cnf with the following:
pastie of my.cnf and i've chown it to mysql:mysql and chmoded it to 777. No matter what I try when I run a few queries nothing gets logged. What am I doing wrong? I have also tried commenting out general_log_file and general_log and use log = and its its the same thing.
update: i did restart mysql after changes.
update: here is the mysql variables: http://pastie.org/5517087
I suggest you to check the following:
1) Make sure that you restarted the service and that no errors appear during the restart, either on the command prompt, or in the mysql error log file
2) In your my.cnf you are using:
general_log_file = /var/www/logs/mysql-query.log
make sure that the user mysqld (or whatever your mysql service is running as), has the proper permissions to write this folder. The /var/www/ folder is usually intended for apache usage, not mysql usage, so I would suggest /var/log/ or /var/log/mysqld
3) Make sure that the my.cnf you are editing, is the one your mysqld is really running. In many cases when you are using some other software (like cpanel, plesk, etc), the default folders are not used and the configs being used are somewhere else. You can search around your system for other my.cnf using:
locate my.cnf