I have received this error:
Bad SQL query Incorrect key file for table '/tmp/#sql_659_0.MYI'; try to repair it
So, following this suggesttion, I try to edit:
sort_buffer_size=4M
join_buffer_size=4M
But I can not find them. Where are they located on Ubuntu 14.04 machine? There are no such options in /etc/mysql/my.cnf
You can run the command find / -name my.cnf on the terminal.This would work as mentioned here
try finding the location of my.cnf as explained here
Secondly i think the title of this question should be:
Where to find my.cnf in Ubuntu 14.04
If you just want to change the values in the running instance you could do (just fire it as a query from anywhere):
SET #FourMegs = 1024 * 1024 * 4;
SET GLOBAL sort_buffer_size = #FourMegs;
SET GLOBAL join_buffer_size = #FourMegs;
Related
I',m having a huge issue with running MySQL#5.7 on my freshly installed 16" Macbook (with OSX 10.15.1 Catalina) During certain actions I get errors like
PDO::__construct(): MySQL server has gone away.
This is caused by the following error I found in the MySQL log.
2019-11-27T13:24:04.835245Z 0 [Warning] File Descriptor 3226 exceeded FD_SETSIZE=1024
After some research, I tried stuff like sudo launchctl limit maxfiles 65536 200000
When i run launchctl limit i get the follwing data
cpu unlimited unlimited
filesize unlimited unlimited
data unlimited unlimited
stack 8388608 67104768
core 0 unlimited
rss unlimited unlimited
memlock unlimited unlimited
maxproc 4096 4096
maxfiles 524288 524288
This looks fine to me. To get the max processes and max files correct I also tried
sudo sysctl -w kern.maxfilesperproc=524288
my.cnf looks like this
[mysqld]
open_files_limit=999999
local_infile=ON
secure_file_priv=""
max_allowed_packet=1073741824
max_connections=100000
key_buffer_size=2G
innodb_buffer_pool_size=12G
query_cache_size=67108864
query_cache_type=1
query_cache_limit=4194304
table_open_cache=4096
innodb_buffer_pool_instances=24
innodb_sort_buffer_size=2G
sort_buffer_size=1G
innodb_flush_log_at_trx_commit=0
innodb_log_file_size=3G
interactive_timeout=3600
max_connect_errors=1000000
thread_cache_size=4096
log_error=/var/log/mysql/error.log
[mysqld_safe]
open_files_limit=999999
There is of course a solution to change my table_open_cache to a lower value but that hurts performance and before i always had this on a higher number.
Anybody any clue where this FD_SETSIZE is coming from and how to change it so its used properly
rebooting has no effect by the way.
Resource explaining issue: https://expressionengine.com/blog/mysql-5.7-server-os-x-has-gone-away
try setting following environment variables in mysql configuration file (my.cnf)
interactive_timeout = 300
wait_timeout = 300
I was having this issue on Big Sur v 11.6. The solution for me was modifying the MySQL config with:
max_allowed_packet=256M
table_open_cache=250
I want to see mysql queries [history, log] [select,insert,update,...] [which i executed] !
Can anyone help me on this ?
I'm using MySQL Version : 5.5.8 [which i got from WAMP]
I tried changing settings from console, and failed ! [change gets lost after restart]
i've asked it before, but no working answer !
Sourav's answer no longer works. As of July 2013, you need:
general-log=1
general-log-file = "C:\wamp\logs\mysql_general.log"
Change the following settings in my.ini:
[mysqld]
port=3306
long_query_time = 1
slow_query_log = 1
slow_query_log_file = "E:/wamp/logs/slowquery.log"
log = "E:/wamp/logs/genquery.log"
How can I view mysql slow_query_log to see which query is taking too much time?
First, you need to check if it's enabled in your MySQL configuration (mysql.ini or mysql.cnf, depending on your system):
# enable slow log:
slow_query_log = 1
# log queries longer than n seconds:
long_query_time = 5
# where to log:
slow_query_log_file = /path/to/your/logs/mysql-slow.log
Restart your MySQL server, then watch the logfile using whatever program you like - tail is the simplest:
tail -f /path/to/your/logs/mysql-slow.log
You may need to play a bit with the long_query_time setting to find the limit where the volume of logging isn't too low or too high, but just right.
Check the location of this log in my.ini file, and then open it in any text editor.
if you ask google for "slow_query_log", this is the first hit - explaining all you need to know. you have to enable it, set a filename you like (if it's already set, you can find the configuration in you my.ini), start your queries and look ito that file...
If you're running mysqld < 5.2, your my.cnf may look like
log-slow-queries=/var/log/mysql/mysql-slow.log //where to store log
long_query_time=3 //quickest query to log
I followed the instructions here: http://crazytoon.com/2007/07/23/mysql-changing-runtime-variables-with-out-restarting-mysql-server/ but that seems to only set the threshold.
Do I need to do anything else like set the filepath?
According to MySQL's docs
If no file_name value is given for --log-slow-queries, the default name is
host_name-slow.log. The server creates the file in the data directory unless
an absolute path name is given to specify a different directory.
Running
SHOW VARIABLES
doesn't indicate any log file path and I don't see any slow query log file on my server...
EDIT
Looks like I'm using server version 5.0.77, so I needed to do:
SET GLOBAL log_slow_queries = 1;
but I get: ERROR 1238 (HY000): Variable 'log_slow_queries' is a read only variable
I assume I'm going to need to restart the server and have log_slow_queries set in my config?
Try SET GLOBAL slow_query_log = 'ON'; and perhaps FLUSH LOGS;
This assumes you are using MySQL 5.1 or later. If you are using an earlier version, you'll need to restart the server. This is documented in the MySQL Manual. You can configure the log either in the config file or on the command line.
For slow queries on version < 5.1, the following configuration worked for me:
log_slow_queries=/var/log/mysql/slow-query.log
long_query_time=20
log_queries_not_using_indexes=YES
Also note to place it under [mysqld] part of the config file and restart mysqld.
Find log enabled or not?
SHOW VARIABLES LIKE '%log%';
Set the logs:-
SET GLOBAL general_log = 'ON';
SET GLOBAL slow_query_log = 'ON';
MySQL Manual - slow-query-log-file
This claims that you can run the following to set the slow-log file (5.1.6 onwards):
set global slow_query_log_file = 'path';
The variable slow_query_log just controls whether it is enabled or not.
I think the problem is making sure that MySQL server has the rights to the file and can edit it.
If you can get it to have access to the file, then you can try setting:
SET GLOBAL slow_query_log = 1;
If not, you can always 'reload' the server after changing the configuration file. On linux its usually /etc/init.d/mysql reload
These work
SET GLOBAL LOG_SLOW_TIME = 1;
SET GLOBAL LOG_QUERIES_NOT_USING_INDEXES = ON;
Broken on my setup 5.1.42
SET GLOBAL LOG_SLOW_QUERIES = ON;
SET GLOBAL SLOW_QUERY_LOG = ON;
set ##global.log_slow_queries=1;
http://bugs.mysql.com/bug.php?id=32565
Looks like the best way to do this is set log_slow_time very high thus "turning off" the slow query log. Lower log_slow_time to enable it. Use the same trick (set to OFF) for log_queries_not_using_indexes.
If you want to enable general error logs and slow query error log in the table instead of file
To start logging in table instead of file:
set global log_output = “TABLE”;
To enable general and slow query log:
set global general_log = 1;
set global slow_query_log = 1;
To view the logs:
select * from mysql.slow_log;
select * from mysql.general_log;
For more details visit this link
http://easysolutionweb.com/technology/mysql-server-logs/
This should work on mysql > 5.5
SHOW VARIABLES LIKE '%long%';
SET GLOBAL long_query_time = 1;
I've bee tearing my hair out trying to get MySQL 5 running on CentOS 5 but I've had hardly any luck.
If I leave everything as default, and launch the initial install it works a charm, but if I tell the my.cnf to use a different drive to store the data, I continuously get the "Timeout error occurred trying to start MySQL Daemon." error.
My.cnf is as follows:
[mysqld]
datadir=/database/mysql
socket=/database/mysql/mysql.sock
user=mysql
old_passwords=1
log-error=/database/log/mysqld.log
long_query_time = 10
log_slow_queries = /database/log/mysql-slow.log
query-cache-type = 1
query-cache-size = 8M
innodb_file_per_table
skip-bdb
set-variable = local-infile=0
[mysqld_safe]
pid-file=/var/run/mysqld/mysqld.pid
The folders all have the right privileges and the mysqld.log doesn't have any error messages in there, according to it, MySQL launced successfuly.
Oh, and /database is a mounted drive, but even if I trial it on a local directory, I get the same error.
Any ideas what could be going wrong? i've seriously waisted more than 5 hours on this now :(
CHEERS
Shouldn't the datadir be set to the other drive and everything else (socket) point to the standard install locations?
Did you check selinux settings? Make sure it is disabled (setenforce disabled), or spent some time learn about it (chcon command) To disable on boot look into /etc/sysconfig
Run the command : getenforce, if it says "Enforced", SE-Linux is On