-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set autocommit to 0 #4113
Open
BlankEclair
wants to merge
1
commit into
miraheze:master
Choose a base branch
from
BlankEclair:autocommit-0
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Set autocommit to 0 #4113
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Reconsider global autocommit disable
Based on the PR discussion and configuration analysis, disabling autocommit globally presents significant risks:
Recommended approach:
Keep
autocommit=1
but implement:If proceeding with
autocommit=0
:Would you like help creating:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please suggest more options for how we can deal with bad SQLs, consider something that would allow setting this for only cli sessions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RhinosF1, certainly! Here are some options to help you deal with bad SQL statements and configure
autocommit=0
specifically for CLI sessions:Use
init_connect
to Disable Autocommit for Non-SUPER Users:Set the
init_connect
global variable to executeSET autocommit=0;
whenever a user connects:Note:
init_connect
does not apply to users with theSUPER
privilege. Ensure that CLI users do not haveSUPER
privileges to enforce this setting.Conditional
init_connect
Based on User or Host:Modify
init_connect
to conditionally disable autocommit based on the connecting user:Replace
'cli_user'@'localhost'
with the appropriate user and host for CLI sessions.Client-Side Configuration in
my.cnf
:Update the MySQL client configuration to disable autocommit for CLI sessions:
Add this to the global
/etc/mysql/my.cnf
or users' personal~/.my.cnf
files under the[mysql]
section. This ensures that whenever themysql
CLI is used, autocommit is disabled for that session.Create a Wrapper Script for the MySQL CLI:
Develop a shell script that sets autocommit to 0 upon connection:
Have users invoke this script instead of the
mysql
command to ensure autocommit is disabled during their sessions.Restrict Direct Database Access:
Limit direct access to the database by:
sql.php
) that handle transactions properly.START TRANSACTION;
) explicitly during manual interventions.Implement a SQL Proxy with Session Initialization:
autocommit=0
for specific users or hosts.Educate and Enforce Best Practices:
Additional Suggestions:
Audit and Logging:
Automate Backups Before Manual Changes:
Review and Approval Processes:
Feel free to let me know if you'd like assistance implementing any of these options or exploring them further.