How do I set the isolation level of MySQL 5.1 InnoDB?
By entering:
mysql> show variables like '%isola%';
The default level set for InnoDB is repeatable read.
How do I change the isolation level?
How do I set the isolation level of MySQL 5.1 InnoDB?
By entering:
mysql> show variables like '%isola%';
The default level set for InnoDB is repeatable read.
How do I change the isolation level?
SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SESSION
is optional, just limits the setting to the current session.
READ UNCOMMITTED
is to be replaced with your desired level.
https://dev.mysql.com/doc/refman/8.0/en/set-transaction.html
You can set 4 transaction isolation levels with 4 scopes as shown below. *The doc explains how to set transaction isolation level in more detail and my answer explains how to show transaction isolation level in MySQL:
With PERSIST scope, transaction isolation level is not reset even after restarting MySQL:
SET PERSIST TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
Or:
SET PERSIST transaction_isolation = 'READ-UNCOMMITTED';
Or:
SET @@PERSIST.transaction_isolation = 'READ-UNCOMMITTED';
With GLOBAL scope, transaction isolation level is reset after restarting MySQL:
SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
Or:
SET GLOBAL transaction_isolation = 'READ-COMMITTED';
Or:
SET @@GLOBAL.transaction_isolation = 'READ-COMMITTED';
With SESSION scope, transaction isolation level is reset after logging out of MySQL:
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
Or:
SET SESSION transaction_isolation = 'REPEATABLE-READ';
Or:
SET @@SESSION.transaction_isolation = 'REPEATABLE-READ';
Or:
SET transaction_isolation = 'REPEATABLE-READ';
With no scope, transaction isolation level is reset after performing the next single transaction:
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
Or:
SET @@transaction_isolation = SERIALIZABLE;
Simply add it to the connection string, when connecting to the mysql database.
?sessionVariables=transaction_isolation='READ-COMMITTED'
You can check for the values of other isolation levels.
My default isolation level is also was REPEATABLE READ with the example above you can change it for current session but if you want to change it entirely you can try with this command:
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
Tested on Mysql server version: 5.7.23-0ubuntu0.18.04.1 (Ubuntu)
© 2022 - 2024 — McMap. All rights reserved.