Set a persistent global MySQL parameter - mysql

I set the following MySQL parameter:
set global wait_timeout=2147483
However, after server restart it reverted to its default value 28800. Isn't the set command persistent? In order to have this parameter persistent, should I edit a configuration file? Would that file be C:\Program Files\MySQL\MySQL Server 5.5\my.ini? If so, is it simply
wait_timeout=2147483
If so, under which section should it be in my.ini

Set global doesn't make persistent variables.
You should write that under [mysqld] section in my.cnf:
[mysqld]
wait_timeout=86400

Related

Unable to set sql_mode in my.cnf

I want to set sql_mode to NO_ENGINE_SUBSTITUTION only.
I modified my.cnf and added this line:
sql_mode=NO_ENGINE_SUBSTITUTION
restarted mysql service but when I execute this query:
show variables like '%sql_mode%'
that's what I get:
How can I fix this issue? I am using vps bought via godaddy.
It's possible to set sql_mode for the session.
SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION'
You can verify the setting with the SHOW VARIABLES statement.
To change the global setting:
SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION'
To have the global setting initialized when the MySQL server restarts, the setting can be configured in the configuration file(s) e.g. my.cnf.
I believe that setting needs to be under the [mysqld] section of the configuration file. Note that there may be more than one configuration file being read. There might be a /usr/my.cnf file that contains a setting.
The sql_mode can also be specified as an option on the mysqld startup command line.
Reference:
http://dev.mysql.com/doc/refman/5.6/en/sql-mode.html

group_concat_max_len value gets changed to default on restart

I am changing the value of group_concat_max_len to 15000 using
SET group_concat_max_len=15000;
I achieve what I what but when I restart mysql server, it is set to default 1024.
How can I make it static to 15000, I assume, I should be able to set this value in mysql config file. I added group_concat_max_len=15000 in my.cnf and restarted the server. The value remained same i.e 1024.
Can I set it in a way so that the value remains same when mysql server is restarted?
Yes. You need to put it in the config file :
LINUX: my.cnf file
WINDOWS: my.ini file
[mysqld]
group_concat_max_len=15000
Note: Add this line group_concat_max_len=15000 under mysqld section. You need to restart your MySQL server to see the effect.

How to set global event_scheduler=ON even if MySQL is restarted?

I want to set the event_scheduler global to ON even if MySQL is restarted; how can I achieve this?
SET GLOBAL event_scheduler = ON;
You can set
event_scheduler=ON
in my.ini or my.cnf file, then restart your server for the setting to take effect.
Once set event_scheduler will always remain ON no matter whether your server restarts.
Open your /etc/mysql/my.ini file and add:
event_scheduler = on
under the [mysqld] section
(tested under mysql 5.5.35-0+wheezy1 - Debian)
One Way - You can set your system variables and use those variables if there is any possibility to restart your mysql.
Here is link Using system variables in mysql
On our Windows Server 2012 system, none of these or any other solutions worked. Then I looked at the registry entry for start up:
"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.6\my.ini" MySQL56
The trick, the evil, is ProgramData. It's not Program Files. Look in Program Files and you'll see a my-default.ini file, put there just to royally screw you up.
The trick is to find the path in the registry, which was for me: HKEY_LOCAL_MACHINE\SYSTEM\Services\MySQL56
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Add this line at the end of the file:
event_scheduler=ON
Than reboot and check if daemon is started after reboot:
Log into mysql bash:
mysql -u <user> -p
Than run the command:
SHOW PROCESSLIST;
Now you should see the event scheduler daemon in the list

MySQL event scheduler in XAMPP

According to the MySQL documentation, to enable the event scheduler permanently I have to insert the following line in the my.ini (there is no my.cnf file in the mysql folder in XAMPP) somewhere in the [mysqld] section:
event_scheduler=ON
But this doesn't seem to work. Every time I restart the computer, the event scheduler is set to OFF, and I have to set it to ON manually (using the SET GLOBAL event_scheduler = ON; command).
Does anybody know a solution for this?
Thanks :)
Here the path for my.ini on XAMPP
xampp\mysql\bin\my.ini
Open my.ini and add the following
[mysqld]
event_scheduler=ON
then restart mySql service.
To check the status use the below mySql query
SELECT ##event_scheduler
The "event_scheduler" with the underscore is the variable name of this option, to turn on the event scheduler in the config file you have to use the correct format with a dash:
event-scheduler=ON
This is a bit confusing as both dash and underscore are used in options in the config file. You should use the server system variables reference when you want to figure out the proper syntax:
http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_event_scheduler
Also, make sure that the option in the configuration file is defined under the [mysqld] header, and not under [client] or [mysqld_safe], because it's not picked up from those places.
XAMPP (xampp-osx-7.2.30-0-installer.dmg) for MAC OS(catalina)
Go to Applications/XAMPP/xamppfiles/etc/my.cnf and add
event_scheduler=ON
on line 39 for instance
The my.cnf files will looks like:
...
# The MySQL server
default-character-set=utf8mb4
[mysqld]
user=mysql
port=3306
socket =/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
key_buffer=16M
max_allowed_packet=1M
table_open_cache=64
sort_buffer_size=512K
net_buffer_length=8K
read_buffer_size=256K
read_rnd_buffer_size=512K
myisam_sort_buffer_size=8M
event_scheduler=ON # ADD THIS LINE
...
Restart the server (MySQl Database from XAMPP console) afterwards !

how to permanently activate/set the global event_scheduler to 1 in mysql

I have added a event to my mySQL db and it works fine, but the thing that is bothering me is that every now and then I have to set the mysql global variable to 1 so that my event is active.I log in as root user and have complete privileges (I use it for practice purpose)
Every time I log in to my mysql server I have to execute the following line
__set global event_scheduler=1__
can I set the event_scheduler variable permanently to 1?
I'm using mysql 5.1.50 - community
Yes, write event_scheduler=on somewhere under the [mysqld] section in the default mysql config file, usually /etc/my.cnf
If you are using WAMP :
Open its control panel by clicking on the WAMP icon -> mysql-> my.ini
Its location may be at:
C:\wamp\bin\mysql\mysql{your.ver.sion}
Add EVENT_SCHEDULER=ON under [mysqld] - not [mysql] notice the "d" for daemon. Another tip to ascertain where you're adding is where your (default) server port is specified.
[mysqld]
port=3306
event_scheduler=on