{"id":8239,"date":"2024-09-20T23:32:02","date_gmt":"2024-09-20T18:02:02","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=8239"},"modified":"2026-09-01T15:15:45","modified_gmt":"2026-09-01T09:45:45","slug":"how-to-disable-strict-trans-tables-in-mysql","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-disable-strict-trans-tables-in-mysql\/","title":{"rendered":"How to Disable STRICT_TRANS_TABLES in MySQL (Temporarily &amp; Permanently)"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>Introduction<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">STRICT_TRANS_TABLES is one of the SQL modes in MySQL that enforces strict data validation rules. When STRICT_TRANS_TABLES is enabled, MySQL rejects invalid values and generates an error, rather than converting them. If a value is missing or invalid, the entire INSERT or UPDATE query is aborted, and no data is inserted. If STRICT_TRANS_TABLES is disabled, MySQL attempts to adjust invalid values to the closest valid ones or uses default values for missing data, allowing the query to succeed but potentially inserting incorrect or unintended values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Prerequisites<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>A sudo-privileged SSH user credential<\/li>\n\n\n\n<li>MySQL &#8220;root&#8221; or any admin-privileged credential<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Implementation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Step 1: Log in to the server via SSH<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ ssh username@IP<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Step 2: Connect to MySQL via the root user or any admin-privileged user<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ mysql -u &lt;username&gt; -p<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Step 3: List the active SQL modes and check whether &#8220;STRICT_TRANS_TABLES&#8221; is included or not. If it is included, then we can consider that it is enabled<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">&gt;SELECT @@GLOBAL.sql_mode;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2024\/09\/Screenshot-2024-09-20-at-11.15.08\u202fPM.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"129\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2024\/09\/Screenshot-2024-09-20-at-11.15.08\u202fPM-1024x129.png\" alt=\"\" class=\"wp-image-8235\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2024\/09\/Screenshot-2024-09-20-at-11.15.08\u202fPM-1024x129.png 1024w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2024\/09\/Screenshot-2024-09-20-at-11.15.08\u202fPM-300x38.png 300w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2024\/09\/Screenshot-2024-09-20-at-11.15.08\u202fPM-768x97.png 768w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2024\/09\/Screenshot-2024-09-20-at-11.15.08\u202fPM-1536x193.png 1536w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2024\/09\/Screenshot-2024-09-20-at-11.15.08\u202fPM-850x107.png 850w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2024\/09\/Screenshot-2024-09-20-at-11.15.08\u202fPM.png 1748w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Step 4: To disable <code>STRICT_TRANS_TABLES<\/code> temporarily by updating the SQL mode for the current session or globally until the server restarts<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(I) For the current session<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&gt;SET SESSION sql_mode = REPLACE(@@SESSION.sql_mode, &#8216;STRICT_TRANS_TABLES&#8217;, &#8221;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">(II) For the global session (until restart)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&gt;SET GLOBAL sql_mode = REPLACE(@@GLOBAL.sql_mode, &#8216;STRICT_TRANS_TABLES&#8217;, &#8221;);<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Step 5: To permanently disable the &#8220;<code>STRICT_TRANS_TABLES<\/code>&#8220;, edit the MySQL configuration. Navigate to the <code>[mysqld]<\/code> section and remove <code>STRICT_TRANS_TABLES<\/code> from the list of SQL modes. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ vi  <code>\/etc\/mysql\/mysql.conf.d<\/code><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2024\/09\/Screenshot-2024-09-20-at-11.22.28\u202fPM.png\"><img decoding=\"async\" width=\"704\" height=\"110\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2024\/09\/Screenshot-2024-09-20-at-11.22.28\u202fPM.png\" alt=\"\" class=\"wp-image-8236\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2024\/09\/Screenshot-2024-09-20-at-11.22.28\u202fPM.png 704w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2024\/09\/Screenshot-2024-09-20-at-11.22.28\u202fPM-300x47.png 300w\" sizes=\"(max-width: 704px) 100vw, 704px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Step 6: Restart the MySQL service<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">$ systemctl restart mysql<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Disabling <code>STRICT_TRANS_TABLES<\/code> can help resolve strict data handling issues for applications requiring more flexible data insertion rules.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. How do I check if STRICT_TRANS_TABLES is enabled in MySQL?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT @@GLOBAL.sql_mode;<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If <code>STRICT_TRANS_TABLES<\/code> appears in the output, it is enabled in the global SQL mode.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also check the SQL mode for your current session:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SELECT @@SESSION.sql_mode;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. How do I disable STRICT_TRANS_TABLES temporarily?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To disable it only for the current MySQL session, run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SET SESSION sql_mode = REPLACE(@@SESSION.sql_mode, 'STRICT_TRANS_TABLES', '');<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The change applies only to the current session.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. How do I disable STRICT_TRANS_TABLES globally?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">SET GLOBAL sql_mode = REPLACE(@@GLOBAL.sql_mode, 'STRICT_TRANS_TABLES', '');<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This changes the global setting, but the change may not persist after the MySQL server is restarted.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Related Articles:<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/configuring-mysql-to-listen-on-a-private-ip-address\/\" data-type=\"link\" data-id=\"https:\/\/pheonixsolutions.com\/blog\/configuring-mysql-to-listen-on-a-private-ip-address\/\">https:\/\/pheonixsolutions.com\/blog\/configuring-mysql-to-listen-on-a-private-ip-address\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-disable-lock-a-mysql-user-account-from-cli\/\">https:\/\/pheonixsolutions.com\/blog\/how-to-disable-lock-a-mysql-user-account-from-cli\/<\/a> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/how-to-copy-a-table-from-one-database-to-another-in-mysql\/\">https:\/\/pheonixsolutions.com\/blog\/how-to-copy-a-table-from-one-database-to-another-in-mysql\/<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Talk to our experts<strong>:<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Looking for the right technology solution for your business? Our experts can help with <strong>web hosting, domain registration, DevOps and cloud, software development, web applications, mobile applications, and enterprise solutions<\/strong>. Get in touch with our team <a href=\"https:\/\/pheonixsolutions.com\/contact\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction STRICT_TRANS_TABLES is one of the SQL modes in MySQL that enforces strict data validation rules. When STRICT_TRANS_TABLES is enabled, [&hellip;]<\/p>\n","protected":false},"author":495,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022,1043],"tags":[988],"class_list":["post-8239","post","type-post","status-publish","format-standard","hentry","category-web-architecture","category-mysql","tag-strict_trans_tables-in-mysql","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-28T","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/495"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=8239"}],"version-history":[{"count":8,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8239\/revisions"}],"predecessor-version":[{"id":11282,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/8239\/revisions\/11282"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=8239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=8239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=8239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}