I m using SSH connect, to remote Mysql database.
unfortunately i can't edit the data, because the mode is READ ONLY,
i have tried grant all permission for user root, but still in READ ONLY mode,
how to change the READ ONLY mode to editable data mode?
Update
and tried set GLOBAL read_only = false;
you can also read only on and off with a couple of methods
Method 1
read only on
SET GLOBAL read_only = ON;
read only off
SET GLOBAL read_only = OFF;
Method 2
read only on
update replicationstatus set writable=0;
read only off
update replicationstatus set writable=1;
You can also set read-only on and off with a couple of different methods:
Method 1
#read only on
SET GLOBAL read_only = ON;
#read only off
SET GLOBAL read_only = OFF;
Method 2
#read only on
update replicationstatus set writable=0;
#read only off
update replicationstatus set writable=1;
Related
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")
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.
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
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.
I have an old application that started failing after an upgrade from MySQL 5.0 to 5.1.
A bit of research indicated this is due to "strict mode" which prevents inserting certain types of "invalid" values which previously were just automatically converted to something reasonable.
I tried SET ##SESSION.sql_mode = '' and SET ##GLOBAL.sql_mode = '' but I still get the error.
Also tried commenting out sql_mode in the my.ini.
Is there a stronger, sort of "nuclear" option to fix this?
In my application I usually make sure that the MySQL connection is using traditional mode by issuing
SET SESSION sql_mode = 'ANSI_QUOTES,TRADITIONAL'
on each new connection. I presume that if you just issue
SET SESSION sql_mode = ''
on each new connection, you will have solved the problem.
You should be able to change the default SQL mode for new connections by issuing
SET GLOBAL sql_mode = ''
but you must use an account with sufficient privileges to do this or it won't work.
I think that if you want to make sure a particular SQL mode is in operation for your application, the most robust way to do so is to set it for each and every new connection.
To allow invalid dates, you need:
SET sql_mode = 'ALLOW_INVALID_DATES';
But you'd better fix your application.