XAMPP MySQL - Setting ft_min_word_len - mysql

I have XAMPP installed on my computer, and am using MySQL through it on localhost for a personal project.
I am trying to set the ft_min_word_len variable for fulltext searches in boolean mode to 2 from the default of 4.
I've tried (after stopping MySQL from the XAMPP control panel):
Opening Shell from the XAMPP control panel, and typing at the prompt:
mysqld ft_min_word_len=2
This doesn't appear to have any effect on ft_min_word_len when I check its value afterwards with mysqld --help --verbose (I get an error when I try to use mysqladmin variables at the prompt).
Creating a my.cnf file in XAMPP\mysql\bin with this text:
# The MySQL server
[mysqld]
ft_min_word_len=2
This does appear to change the value of ft_min_word_len when I check its value with mysqld --help --verbose.However, when I start MySQL again from XAMPP's control panel, and then check the value of ft_min_word_len through PHPMyAdmin with SHOW VARIABLES LIKE 'ft_min_word_len', it is still 4, both before and after I rebuild the fulltext indexes.
I've tried each approach multiple times, in between stopping and starting MySQL. SHOW VARIABLES LIKE 'ft_min_word_len' did show a value of 2 once, but the next time I stopped and restarted MySQL, the value had returned to 4, and I have been unable to set it to 2 again.
Any pointers in the right direction would be appreciated.

mysql config file would usually be found on in windows your installation drive:\XAMPP\mysql\bin\my.ini or
Linux under etc\my.cnf.
if you does not get ft_min_word_len variable below the lines you simply add those line anywhere in the page
[mysqld]
ft_min_word_len = 3
then restart mysql server.

Keep you my.cnf file in <XAMPP>\mysql\bin folder and try again.

Related

Mysql : can't set lower_case_table_names variable

I'm installing new software on a new Ubuntu 16.0.4 machine and installed MySQL with apt-get. The version I get is 5.7.22 but can't get it to accept
my settings of the configuration variable lower_case_table_names.
I'm adding lines like:
[mysql]
lower_case_table_names = 1
When I edit any of the *.cnf files in /etc/mysql to have this setting or if I add it to ~/.my.cnf I get
mysql: [ERROR] unknown variable 'lower_case_table_names=1'
if I try to start mysql. Similarly I can't use it on the mysql command line like the doc says I can.
/usr/bin/mysql --lower_case_table_names=1 -u root -p
However:
If I go into the SQL command interpreter and type
mysql> select ##lower_case_table_names;
I get back a result showing the variable is set to 0. However it cannot be changed with a SET statement...
So whats the deal with why I can't set this variable ?
~/.my.cnf file:
[mysqld]
lower_case_table_names = 1
[mysql]
lower_case_table_names = 1
Why is mysql not liking this variable name when clearly it still has a setting for it?
The problem is that this variable does not apply to mysql. It only applies
to mysqld. Stop mysqld, change the my.cnf to have a setting for [mysqld], and then start mysqld. This will set the lower_case_table_names value for the mysql server.
If you run /usr/bin/mysql (a command line mysql shell) it will not want a setting for this var in the config file. The shell will behave as the mysql server behaves.

change secure-file-priv in mysql on osx

I am trying to print my result tables into a csv file or a text file and I use into outfile in mysql but I get this error:
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
I have tried to set this secure-file-priv to "" but i cant really find my.cnf file in my mac. The locate result of my.cnf is like:
/usr/local/Cellar/mysql/5.7.16/mysql-test/include/default_my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/federated/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_big/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_binlog/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_ddl/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_memcache/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_rpl/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndb_team/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/ndbcluster/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/rpl/extension/bhs/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/rpl/my.cnf
/usr/local/Cellar/mysql/5.7.16/mysql-test/suite/rpl_ndb/my.cnf
I dont think any of them is the one that I need to add [mysqld] secure-file-priv="" to.
Also I tried to set it in mysql but it's read only and I cannot change it. I even tried to to stop and restart my mysql after adding a my.cnf file manually in /etc/ but then I was not able to start the server again and use mysql.
I am using mysql Ver 14.14 Distrib 5.7.20, for osx10.12 (x86_64)
Followed below steps to changes -secure-file-priv
Look for "my.cnf" file which is located at /usr/local/etc
add secure-file-priv = "" into my.cnf
restart mysql using /usr/local/opt/mysql/support-files/mysql.server restart
After restart I am able to use OUTFILE command on mysql.
I reviewed setting on MySQL Workbench.
In "Options Files", it was set to the correct value. But in "Administration - Status and System Variables", it keeped as default value NULL. Although I restarted the server.
After some researches, I found it was cased by the wrong file permission. What I had at the beginning is:
-rw------- 1 root wheel 31 Mar 24 13:31 my.cnf
And I use command chmod 0755 changed the permission to:
-rwxr-xr-x 1 root wheel 31 Mar 24 13:31 my.cnf
Then restart the server, I can see both "Options Files" and "Administration - Status and System Variables" have the same value and status.
This is what it looks like on my server. I can't put a screen shot into the comments.

cannot find mysql slow query log file on mac

I am trying to enable slow_query_log on mysql, but I could not find it on my mac.
I read in MySQL 5.7 Documentation that"
By default, the server writes files for all enabled logs in the data directory.
When I write show variables like '%slow_query%'; in mysql shell, I see the following:
but I can't see McBook-Pro-6-slow.log in the data directory. Here is all I can see in the data directory:
Could someone let me know why I can't see the slow log file?
In order to enable the slow_query_log, I've read here that I should add slow-query-log=1 to my.cnf. Here, my problem is that I am not sure where is mysql config file on my Mac. I've found a my-default.cnf in usr/local/mysql/support-files/ and another my.cnf file in /etc. Which one should I modify??
Thanks,
Refer to this Stackoverflow question MySQL 'my.cnf' location? which pertains to Mac OS. As you can see the permutations of locations are numerous usually compounded by different distros and MAMP XAMP WAMP bundles and Home Brew. It is not uncommon to have 2 mysql daemons on a box and not even know it.
Which is why in comments I suggested looking at the output of select ##basedir for the location of the my.ini (Windows) or my.cnf (Linux/Mac). That is not to suggest a configuration file is going to be there, but that is where it should be if one were to exist. Without it, baked-in default values are used. Often there is a stub, a suggested file, named differently (like my-default), awaiting your tweaks and a rename or copy to the appropriate file name of my.ini or my.cnf.
There is also a system variable named slow_query_log_file and its value visible if set thru SELECT ##slow_query_log_file;. For me right now it has a value of GUYSMILEY-slow.log because I did not set it in my ini (Windows) and it defaults to computername+"-slow.log".
That is the filename without the path. Where the file actually is written to is in the datadir seen with the output of select ##datadir;.
On my system this means (via ##basedir)
C:\Program Files\MySQL\MySQL Server 5.6\my.ini
would have a setting that ends up in a slowlog file written to in this absolute path (helped by ##datadir):
C:\ProgramData\MySQL\MySQL Server 5.6\data\GUYSMILEY-slow.log
and a fragment inside that log file might show something like this:
Ini and cnf changes require a MySQL daemon restart. In that configuration file a section similar to (my 5.6)
[mysqld]
basedir=C:\\Program Files\\MySQL\\MySQL Server 5.6\\
datadir=C:\\ProgramData\\MySQL\\MySQL Server 5.6\\Data\\
port=3306
log_warnings = 2
and (my 5.7)
[mysqld]
basedir=C:\\Program Files\\MySQL\\MySQL Server 5.7\\
datadir=C:\\ProgramData\\MySQL\\MySQL Server 5.7\\Data\\
port=3307
log_error_verbosity=2
the above is used within the [mysqld] section to play with settings. What I suggest is playing with this section with an innocuous setting like log_error_verbosity (5.7.2 and up) or similar, save it. Restart the deamon and determine if the variable (as Rick James would call settings because most really aren't dynamically settable). So a sanity check of select ##log_error_verbosity (5.7.2 and up) can confirm it the change is picked up. If it is, bingo, you are doing it right.
The Manual Page Server System Variables depicts the variables (settings) and whether or not they can be dynamically set/changed after the config file load via commands. Dynamic changes are reverted upon daemon restart.
How one would dynamically change a variable might look like:
SET GLOBAL log_error_verbosity=2;
Again, only certain variables are available in certain MySQL versions, such as the above, not available in older versions.
Also note multiple versions of MySQL running concurrently on a server. On mine i have 5.6.31 and 5.7.14. To access a different one via command line tools, use something like the -P 3307 switch to point at the one running on port 3307. Note the uppercase P as opposed to lowercase (which would mean prompt for password).
Determine if multiple instances are running. I use port checks such as
sudo netstat -tulpn (Linux)
netstat -aon | more (Windows, the top part, State=LISTENING)
Unfortunately these types of changes and trial and error take time and are very frustrating. Sorry I do not have a quick and easy answer for all cases.
Addendum
Notes here related to comments. In the below, w-x-y-z is a redacted IP Address.
On a Linux box (amazon ec2 redhat btw):
select ##slow_query_log;
-- 0 (so it is turned off)
SELECT ##slow_query_log_file;
-- /var/lib/mysql/ip-w-x-y-z-slow.log
select ##version;
-- 5.7.14
set global slow_query_log=1;
Error Code: 1227. Access denied; you need (at least one of) the SUPER privilege(s) for this operation 0.094 sec
(ok I was in MySQL Workbench as a dummied down user, off to do it as root via MySQL cmd line ...
mysql> set global slow_query_log=1;
Query OK, 0 rows affected (0.01 sec)
mysql> select ##slow_query_log;
+------------------+
| ##slow_query_log |
+------------------+
| 1 |
+------------------+
1 row in set (0.00 sec)
btw Workbench user can confirm the above `1`
at shell as linux user:
[ec2-user#ip-w-x-y-z ~]$ cd /var/lib/mysql
[ec2-user#ip-w-x-y-z mysql]$ sudo ls -la
(there were many files, only one needed to show you below)
-rw-r-----. 1 mysql mysql 179 Sep 19 01:47 ip-w-x-y-z-slow.log
[ec2-user#ip-w-x-y-z mysql]$ sudo vi ip-w-x-y-z-slow.log
(Header stub, the entire contents, no slow queries yet, log seen below):
/usr/sbin/mysqld, Version: 5.7.14 (MySQL Community Server (GPL)). started with:
Tcp port: 3306 Unix socket: /var/lib/mysql/mysql.sock
Time Id Command Argument
SHOW VARIABLES LIKE 'log_output'; to verify that it is set to FILE or FILE,TABLE.

MySQL Error Code: 1238. Variable 'ft_min_word_len' is a read only variable

How do I change the ft_min_word_len variable in mysql?
I tried to run the command set ft_min_word_len = 3; but It returns me the following error:
Error Code: 1238. Variable 'ft_min_word_len' is a read only variable
In debian/ubuntu OS you can change the value of ft_min_word_len by updating the my.cnf file
The location of the file is usually under
/etc/mysql
So go to the above folder and type
sudo vi my.cnf
Then in the file check for the block [mysqld] and see if the variable is already there if not then just add the line
ft_min_word_len = 3
Save it and and restart mysql
sudo /etc/init.d/mysql restart
or
sudo service mysql restart
If you already had the full text indexes on a table before doing the above operation, after above changes drop the indexes and rebuit or you can do a repair the table from mysql terminal something as
repair table table_name quick
put in my.cnf
[mysqld]
ft_min_word_len = 3
Only Dynamic Variable can be changed while MySQL is running. ft_min_word_len is not a dynamic variable. You can see MySQL Manaual (http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_ft_min_word_len)
So you can change it's value as other answerer mentioned.
Please note that if there are tables which already has fulltext index, they need to be rebuilt to affect ft_min_word_len changed.

Mysql: modification in my.cnf doesn't take effect

I've updated the my.cnf file of my database with the following line: max_connections=200. I stopped and started the mysql service after that so that the changes would take effect.
But for some reason this change doesn't affect the database because if I run:
mysql> select ##max_connections
it shows that the max number of connections is 100.
Obviously there is some place else that manages this value. Where can I find it or what did I do wrong?
Thank you for your reply.
Make sure the max_connections in under the [mysqld] section:
Ex:
[mysqld]
socket=/path/to/mysql.sock
datadir=/var/lib/mysql
max_connections=200
[client]
#mysql-client settings here..
Try running mysqld --verbose --help to see which configuration file is actually read by mysqld and which parameters and values are used.
The output will look like this:
mysqld Ver 5.0.51a-24-log for debian-linux-gnu on x86_64 ((Debian))
Copyright (C) 2000 MySQL AB, by Monty and others
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Default options are read from the following files in the given order:
/etc/mysql/my.cnf ~/.my.cnf /usr/etc/my.cnf
The following groups are read: mysql_cluster mysqld server mysqld-5.0
Variables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- -----------------------------
...
To see what values a running MySQL server is using, type
'mysqladmin variables' instead of 'mysqld --verbose --help'.
Changes to mysqld are not necessarily reflected in the mysql client! I changed a global variable assignment in my.cnf, restarted the service, and queried it in the mysql client. It returned the old value. When queried from a script, however, the value was in fact changed!
It may have to do with 'how' the mysql server is being shutdown and restarted. On my system if I use the mysqld daemon service to shutdown mysql (e.g. service mysqld stop), I get a shutdown notice, but a ps shows mysql is still running. Using a similar 'service mysqld restart', some of the changes to the my.cnf file get accepted, but many don't.
The other method of shutting down mysql is to use mysqladmin -u user -pPass shutdown. I noticed when I used this method, mysql was shutdown completely (no left overs in ps), and when I restarted the mysql server, all the changes to the my.cnf file were accepted.
If mysql starts as a Window service, check the 'Path to executable' setting on the windows service. (Services -> MYSQL56 -> Properties).
If the --defaults-file option is passed in, it could point to a completely different .ini file in a location that is NOT showing with 'mysqld --verbose --help'.
If you remove the --defaults-file option from the service startup parameters, it will go through the list of ini files as listed with mysqld --verbose --help.
Putting my.cnf in /etc/my.cnf and restarting mysql has resolved the issue for me. I'm using mac os. Mysql version is 5.6.41