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
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.
You can set 4 transaction isolation levels with 4 scopes as shown below. *You can check more details on 13.3.7 SET TRANSACTION Statement.
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';
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';
With SESSION
scope, transaction isolation level is reset after logging out MySQL:
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
Or:
SET SESSION 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';
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)