Change mysql system variable without restart - mysql

Is there any way to change value of "skip_name_resolve" variable on windows mysql server without restarting service?
This variable is not dynamic, and cannot be changed with SET query:
mysql> set global skip_name_resolve="ON";
ERROR 1238 (HY000): Variable 'skip_name_resolve' is a read only variable

The MySQL server maintains many system variables that indicate how it
is configured. Section 5.1.4, “Server System Variables”, describes the
meaning of these variables. Each system variable has a default value.
System variables can be set at server startup using options on the
command line or in an option file. Most of them can be changed
dynamically while the server is running by means of the SET statement,
which enables you to modify operation of the server without having to
stop and restart it. You can refer to system variable values in
expressions.
this is taken from http://dev.mysql.com/doc/refman/5.0/en/using-system-variables.html
ideally you should be able to change a variable by just using SET query.

Related

Lamp stack running on google cloud and want to create a replica database

I have to set the mysql server..... log_bin=ON.
I have managed to set the server_id and gtid_mode. I've read some documentation on mysql site.
However cant resolve this is the error.
mysql> SET GLOBAL log_bin=ON ;
ERROR 1238 (HY000): Variable 'log_bin' is a read only variable
Are you running MySQL inside a Compute Engine instance or are you using Cloud SQL? Changing the log_bin variable is currently not supported in Cloud SQL for MySQL (log_bin is not listed as a supported flag) and while a feature request to allow users to change this flag's value was submitted a while ago, changes don't appear to have been implemented as of yet.
If you're running MySQL inside a Compute Engine instance, I would suggest trying to declare --log-bin as a startup option instead.

How to use init_connect in azure database server for mysql

Have created a mysql server which has somehow log_bin set to ON and enforce_gtid_consistency is also set to ON. Now this is causing few issues in my case and i want to turn OFF those variables.
Process i have tried
1. Create a .my.cnf file in user root (~/.my.cnf) and added
[mysqld]
enforce_gtid_consistency=OFF
Result: No changes. It doesnt take effect.
2. In azure portal in init_connect variable i have set "SET enforce_gtid_consistency=OFF;" (because there is no mention of this variable in server parameters).
Result: Cant connect to mysql after setting up value in this parameter.
Is there any way we can fix this?
May be the following doc is helpful:
https://learn.microsoft.com/en-us/azure/mysql/concepts-read-replicas#global-transaction-identifier-gtid
Once GTID is enabled, you cannot turn it back off. If you need to turn GTID OFF, please contact support.

Configure max_allowed_packet on mySQL SERVER on AWS-EC2

I have an EC2 instance created with a MySQL server instance installed.
Since i am sending large blob data to be stored in the server, and the max_allowed_packet configuration is set to value 1048576, my service requests are failing.
I am trying to increase the size of the parameter to 16MB by using the below command via putty.
SET GLOBAL max_allowed_packet=16777216;
But there is no effect in the parameter. I tried restarting the sql server instance, still the effect isnt seen.
When i run the below command again after setting the parameter, the same old value is shown 1048576.
SHOW VARIABLES LIKE 'max_allowed_packet';
What am i missing here?
Update the MySQL server's configuration file /etc/my.cnf under [mysqld] section with the new value for max_allowed_packet
[mysqld]
max_allowed_packet=16M
and restart the server.
Values set via SET statement are not persisted across server restarts and are applied only on the new client sessions created after the change.
Excerpt from the documentation,
If you change a global system variable, the value is remembered and
used to initialize the session value for new sessions until you change
the variable to a different value or the server exits. The change is
visible to any client that accesses the global value. However, the
change affects the corresponding session value only for clients that
connect after the change. The global variable change does not affect
the session value for any current client sessions (not even the
session within which the global value change occurs).

Mysql 5.7.21 inconsistent only_full_group_by behavior with EF6 and Mysql Connector 6.9.9

We just upgraded our Mysql db from 5.6 to 5.7.21.
Then all the sql statements that are written against sql_mode:only_full_group_by gave error. That's the normal behavior of Mysql 5.7.21 because sql_mode parameter in my.ini was set to "ONLY_FULL_GROUP_BY".
Then we set this parameter to empty string ("") in my.ini and restarted server again. Everything seemed normal for just a 1 or 2 minutes , then the same queries began to give only_full_group_by error again.
We are still trying to find a solution without touching our codebase bu we couldn't yet.
You can see a live exmaple in this link
Please refreseh the page 10 times or more to get the page work.
http://www.karoltekstil.com.tr/atlet-ust-giyim/k/10-42?page=1
Each MySQL session (database connection) has its own setting for sql_mode.
When a new session is started (a new connection is made to the database), the sql_mode session variable inherits the setting of the global sql_mode setting.
While a session is running, it can change the setting of its own sql_mode, for example by issuing a statement like this:
SET ##session.sql_mode = 'ONLY_FULL_GROUP_BY' ;
The new value of sql_mode remains in effect for that session, until it is changed again, or until the session ends.
A user with sufficient privilege can also change the global setting of sql_mode, with a statement like this for example:
SET ##global.sql_mode = 'ONLY_FULL_GROUP_BY' ;
Any change made the global setting only affects new sessions (connections started after the change is applied.) Changes to the global setting don't influence sessions that are already started. The existing sessions already have their "copy" of sql_mode that was inherited when the connection was started.
Note that ONLY_FULL_GROUP_BY can be explicit in sql_mode, or it can be included implicitly in a combination setting. For example, sql_mode='ANSI' includes ONLY_FULL_GROUP_BY.
MySQL startup has a variety of locations that it reads configuration information from, whether that's my.ini, my.cnf, or options provided on the command line of the startup.
Next steps in debugging this is to determine if sql_mode is being set properly when the database starts, and then determine if there are statements being executed in individual sessions that change the setting of sql_mode.
Is the application churning database connections, starting and ending discrete sessions?
Or is the application using a connection pool, persistent connections that are borrowed and returned from the pool?

When using rails/activerecord to talk to a MySQL database, can I set max_allowed_packet?

MySQL has a setting called 'max_allowed_packet' which is set separately for clients and servers. On the server side it's in a config file, is it possible to set this to a non-default value on the client side when the client is rails ActiveRecord?
From the documnentation
On the client side, max_allowed_packet has a default of 1GB.
So, you just have to change it on the server side. Depending what version of MySQL you are using, you can do this on the fly on a global basis by running
SET GLOBAL max_allowed_packet=16777216
or
SET max_allowed_packet=16777216
where I assumed a 16MB max size. As you noted, you can also set the global variable in your my.cnf.
Currently, you cannot change this on a per-session basis.
mysql> SET SESSION max_allowed_packet=102400000;
ERROR 1621 (HY000): SESSION variable 'max_allowed_packet' is read-only. Use SET GLOBAL to assign the value
I dont know if could help , but you can set mysql variable at runtime .
ActiveRecord::Base.connection.execute("set global max_allowed_packet=1000000000;")