System variable change doesn't work [duplicate] - mysql

I ran the command as root:
set ##auto_increment_offset = 2;
But the effect cannot be seen from other connections. Why not? It is global.
From http://dev.mysql.com/doc/refman/5.1/en/replication-options-master.html:
"If the global value of either variable is set, its effects persist until the global value is changed or overridden by setting the session value, or until mysqld is restarted."
That doesn't seem to agree with what I am seeing.
Ultimately, I would like to know if there any way to permanently set the offset for all clients without restarting mysqld?

As per MySQL documentation you need to set values of auto_increment_offset for both GLOBAL and SESSION.
SET GLOBAL auto_increment_offset = 2;
SET SESSION auto_increment_offset = 2;
SHOW VARIABLES LIKE '%auto_increment_offset%';
If the global value of either variable is set, its effects persist until the global value is changed or overridden by setting the session value, or until mysqld is restarted. If the local value is set, the new value affects AUTO_INCREMENT columns for all tables into which new rows are inserted by the current user for the duration of the session, unless the values are changed during that session.

To set it globally you should add prefix 'GLOBAL' or '##global.'. For example -
SET ##GLOBAL.auto_increment_offset = 2;
The '##' is the same as 'SESSION' or '##session.', it sets session variable.
Using System Variables.

Related

Setting connection variables w/ sqlalchemy? [duplicate]

I want to set the general_log and general_log_file variables using SQLAlchemy, is there a way to do this? I've been Googling around and can't find anything on the topic.
You can execute any raw SQL query which you need (of course you have to get appropriate rights in the session). To change a variable run something like this:
# change variable name and values to what you need
connection.execute("SET SESSION query_cache_type = OFF")
As mentioned previously, you could use the following code the set a variable using the raw Connection object.
connection.execute("SET SESSION query_cache_type = OFF")
If you have a Session object, you can retrieve the underlying Connection object using the Session.connection() function.
So your code could look as follows.
session.connection().execute("SET SESSION query_cache_type = OFF")

Alternative to MySQL's GROUP_CONCAT function

I'm retrieving the data with MySQL function called "GROUP_CONCAT()".
But when I checked the result of "GROUP_CONCAT()" function related column, it was missing some data.
When I google the record missing issue with "GROUP_CONCAT()" function, in the official MySQL site they have mentioned as,
There is a global variable called group_concat_max_len and it will permit the maximum result length in bytes for the GROUP_CONCAT() function, the default value of it as 1024.
Therefore it seems I have to increase that value with following MySQL command,
SET GLOBAL group_concat_max_len = 1000000;
Therefore set this value permanently, I have to edit the MySQL server related configuration file (my.cnf or my.ini) and have to restart the server.
But unfortunately I haven't any permission to do so.
Therefore can you please help me to find out some alternative solution to fix this issue.
Thanks a lot.
Use SET SESSION instead:
SET SESSION group_concat_max_len = 1000000;
Unlike SET GLOBAL, SET SESSION does not require super privilege.
Reference

What is the maximum allowance for group_concat_max_len in MySQL?

I am using a group_concat to concatenate a lot of rows into one.
I set group concat to 10000 using:
SET group_concat_max_len = 10000;
But even then, my output cells remain incomplete and end with ...
I tried setting group_concat_max_len = 20000 and even that didn't help.
I also tried setting group_concat_max_len to 99999999. It still doesn't complete my output text. And I checked one of the group concat stops at Length = 230 characters and then gives ...
Is there any other way?
Check out this link: https://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_group_concat_max_len
All the MySQL configuration variables are documented on that page, with details like minimum, maximum, default value, whether you can set them globally or per-session, whether you can change them on a running instance or does it require a restart, and other description of usage.
The maximum value for group_concat_max_len is 18446744073709551615.
The group-concat string does not end with "..." If you try to group too much text, it just gets truncated. So I wonder if the problem is not with MySQL's settings, but with the display of your cells.
For 32bit systems, the maximum value is 4294967295
For 64 bit systems, the maximum value is 18446744073709551615.
You can set the variable for your current session using
SET SESSION group_concat_max_len=4294967295;
To set the variable forever use
SET GLOBAL group_concat_max_len=4294967295;
(see http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_group_concat_max_len)

Permanently setting auto_increment_offset in MySQL

I ran the command as root:
set ##auto_increment_offset = 2;
But the effect cannot be seen from other connections. Why not? It is global.
From http://dev.mysql.com/doc/refman/5.1/en/replication-options-master.html:
"If the global value of either variable is set, its effects persist until the global value is changed or overridden by setting the session value, or until mysqld is restarted."
That doesn't seem to agree with what I am seeing.
Ultimately, I would like to know if there any way to permanently set the offset for all clients without restarting mysqld?
As per MySQL documentation you need to set values of auto_increment_offset for both GLOBAL and SESSION.
SET GLOBAL auto_increment_offset = 2;
SET SESSION auto_increment_offset = 2;
SHOW VARIABLES LIKE '%auto_increment_offset%';
If the global value of either variable is set, its effects persist until the global value is changed or overridden by setting the session value, or until mysqld is restarted. If the local value is set, the new value affects AUTO_INCREMENT columns for all tables into which new rows are inserted by the current user for the duration of the session, unless the values are changed during that session.
To set it globally you should add prefix 'GLOBAL' or '##global.'. For example -
SET ##GLOBAL.auto_increment_offset = 2;
The '##' is the same as 'SESSION' or '##session.', it sets session variable.
Using System Variables.

How to set value of mysql MaxNoOfConcurrentOperations

I am getting following error:
Got temporary error 233 'Out of operation records in transaction coordinator (increase MaxNoOfConcurrentOperations)' from NDBCLUSTER
While inserting data into ndb table.
Can anyone explain more about this error. Also in my config.ini I dont have this parameter set. Is there any way I can see the default value of this variable. as I canot see this variable when I am using commmand SHOW VARIABLES.
To set this variable do I also need to change the MaxMaxNoOfConcurrentTransactions and MaxNoOfLocalOperations.
The default value for MaxNoOfConcurrentOperations is 32768 but you can increase this value by editing your ndb_mgm config i.e. /etc/mysql/ndb_mgmd.cnf
and adding something like
MaxNoOfConcurrentOperations=100000
When updaing the MaxNoOfConcurrentOperations value you should also update MaxNoOfLocalOperations. The rule of thumb is to make MaxNoOfLocalOperations 10% larger than MaxNoOfConcurrentOperations so you would have.
MaxNoOfConcurrentOperations=100000
MaxNoOfLocalOperations=110000