{"id":473,"date":"2021-11-26T16:43:00","date_gmt":"2021-11-26T21:43:00","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2012\/11\/26\/how-to-change-mysql-server-time-zone\/"},"modified":"2022-07-15T16:39:18","modified_gmt":"2022-07-15T20:39:18","slug":"how-to-change-mysql-server-time-zone","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/","title":{"rendered":"How to change MySQL server time zone"},"content":{"rendered":"<p>In this article, we\u2019ll discuss how you can <strong>change the MySQL time zone<\/strong> on your server so that data stored in your databases will by default use the time zone that you have specified.<\/p>\n\n\n\n<p>A lot of the time your local time zone will be different than the MySQL server\u2019s time zone, and this could make working with data inside your databases more difficult for you. Using the following steps you can update your MySQL server\u2019s time zone so that it matches your own to make working with this data easier.<\/p>\n\n\n\n<p>This change would require <a href=\"https:\/\/www.inmotionhosting.com\/support\/amp\/obtain-root-access\/\" data-type=\"post\" data-id=\"3444\">root access<\/a> to either a VPS (Virtual Private Server) or dedicated server hosting plan, or you can contact our support department to have this changed on your server. You might also simply need to know <a href=\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-convert-mysql-time\/\">how to convert MySQL time<\/a> which wouldn\u2019t require root access and can be done on a shared server.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"jetpack-video-wrapper\"><div class=\"yt-d7r62AxnU2s\">\n\t<a class=\"play-video-d7r62AxnU2s\" style=\"position: relative; display: flex; flex-wrap: wrap; align-items: center; cursor: pointer;\">\n\t\t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i.ytimg.com\/vi_webp\/d7r62AxnU2s\/maxresdefault.webp\" width=\"1280\" height=\"720\" alt=\"How to Change the MySQL Time Zone\" style=\"width: 100%; height: auto;\">\n\t\t<span class=\"fa fa-imh-play-circle imh-ds-icon play-circle\" style=\"position: absolute; display:block; font-size:150px; color: #c52228; opacity:0;\"><\/span>\n\t<\/a>\n<\/div><\/div>\n<\/div><figcaption>Don\u2019t have time to read the full guide? Watch our walk-through video.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Changing the Time Zone in MySQL<\/h2>\n\n\n\n<ol class=\"article_list wp-block-list\"><li><a href=\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-login-ssh\/\">Login to your server via SSH<\/a> as the root user.<\/li><li>You can view MySQL\u2019s current time zone settings using the following command from the console: <pre>mysql -e \"SELECT @@global.time_zone;\"<\/pre>By default you should get back something similar to:<br>\n<code>+--------------------+ <br>| @@global.time_zone | <br>+--------------------+ <br>| SYSTEM             | <br>+--------------------+ <\/code><p>This is because by default your MySQL time zone will be set to the server\u2019s default <strong>SYSTEM<\/strong> time. If you\u2019re interested in changing the entire server\u2019s time zone this can be accomplished by <a href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/whm\/setting-the-server-time-zone-in-whm\/\">setting the time zone in WHM<\/a>.<\/p> <\/li><li>You can see the server\u2019s <strong>SYSTEM<\/strong> time stamp using the following command:<pre>date<\/pre><br>This will give back something similar to this:<br><code>Mon Nov 26 12:50:07 EST 2021<\/code><\/li><li>You can see the current time stamp reported by the MySQL server using the following command: <pre>mysql -e \"SELECT NOW();\"<\/pre>This should give back the current time stamp:<br><code>+---------------------+ <br>| NOW()               | <br>+---------------------+ <br>| 2021-11-26 12:50:15 | <br>+---------------------+<\/code> <\/li><li>Now you can edit your MySQL configuration file with your favorite text editor:<pre>vi \/etc\/my.cnf<\/pre>Then run the following line to change from EST (<strong>GMT -5:00<\/strong>) to CST (<strong>GMT -6:00<\/strong>):<pre>default-time-zone = '-06:00'<\/pre>Now save the <strong style=\"font-size: revert; color: initial;\">\/etc\/my.cnf<\/strong><span style=\"font-size: revert; color: initial;\"> file with your new default.<\/span> <\/li><li>To make the change active you\u2019ll want to restart the MySQL service with the following command:<pre>service mysql restart<\/pre><\/li><li>Now if you try to see the global time zone setting again with the command:<pre>mysql -e \"SELECT @@global.time_zone;\"<\/pre>You should now get back your new default:<br><code>+--------------------+ <br>| @@global.time_zone | <br>+--------------------+ <br>| -06:00             | <br>+--------------------+<\/code><\/li><li>You should also see now that the <strong>NOW()<\/strong> function has updated as well:<pre>mysql -e \"SELECT NOW();\"<\/pre>This should give back the current time stamp:<br><code>+---------------------+ <br>| NOW()               | <br>+---------------------+ <br>| 2021-11-26 11:50:15 | <br>+---------------------+<\/code><\/li><\/ol>\n\n\n\n<p>You should now know how to update the MySQL server\u2019s time zone setting, to help make sure the data stored in databases is easy for you to work with. You can also used named time zones instead of the <strong>GMT -6:00<\/strong> format, but this would first require you loading the time zone tables into the <strong>mysql<\/strong> database. More information on this can be found on the MySQL site regarding <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/mysql-tzinfo-to-sql.html\" target=\"_blank\" rel=\"noopener\">mysql_tzinfo_to_sql and loading the time zone tables<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we&#8217;ll discuss how you can change the MySQL time zone on your server so that data stored in your databases will by default use the time zone that you have specified. A lot of the time your local time zone will be different than the MySQL server&#8217;s time zone, and this could<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/\"> Read More ><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4305],"tags":[],"class_list":["post-473","post","type-post","status-publish","format-standard","hentry","category-databases"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to change MySQL server time zone | InMotion Hosting<\/title>\n<meta name=\"description\" content=\"In this article we&#039;ll discuss how you can change the MySQL time zone on your server so that data stored in your databases will by default use the time zone that you have specified.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to change MySQL server time zone | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"In this article we&#039;ll discuss how you can change the MySQL time zone on your server so that data stored in your databases will by default use the time zone that you have specified.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-26T21:43:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-15T20:39:18+00:00\" \/>\n<meta name=\"author\" content=\"InMotion Hosting Contributor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InMotion Hosting Contributor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/\"},\"author\":{\"name\":\"InMotion Hosting Contributor\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5fbfcaed32a2672fb83ab312f5b7237b\"},\"headline\":\"How to change MySQL server time zone\",\"datePublished\":\"2021-11-26T21:43:00+00:00\",\"dateModified\":\"2022-07-15T20:39:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/\"},\"wordCount\":487,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Working with Databases\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/\",\"name\":\"How to change MySQL server time zone | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2021-11-26T21:43:00+00:00\",\"dateModified\":\"2022-07-15T20:39:18+00:00\",\"description\":\"In this article we'll discuss how you can change the MySQL time zone on your server so that data stored in your databases will by default use the time zone that you have specified.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to change MySQL server time zone\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5fbfcaed32a2672fb83ab312f5b7237b\",\"name\":\"InMotion Hosting Contributor\",\"description\":\"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/inmotion-hosting\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/john-paul\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to change MySQL server time zone | InMotion Hosting","description":"In this article we'll discuss how you can change the MySQL time zone on your server so that data stored in your databases will by default use the time zone that you have specified.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/","og_locale":"en_US","og_type":"article","og_title":"How to change MySQL server time zone | InMotion Hosting","og_description":"In this article we'll discuss how you can change the MySQL time zone on your server so that data stored in your databases will by default use the time zone that you have specified.","og_url":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2021-11-26T21:43:00+00:00","article_modified_time":"2022-07-15T20:39:18+00:00","author":"InMotion Hosting Contributor","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"InMotion Hosting Contributor","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/"},"author":{"name":"InMotion Hosting Contributor","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5fbfcaed32a2672fb83ab312f5b7237b"},"headline":"How to change MySQL server time zone","datePublished":"2021-11-26T21:43:00+00:00","dateModified":"2022-07-15T20:39:18+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/"},"wordCount":487,"commentCount":3,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Working with Databases"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/","url":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/","name":"How to change MySQL server time zone | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2021-11-26T21:43:00+00:00","dateModified":"2022-07-15T20:39:18+00:00","description":"In this article we'll discuss how you can change the MySQL time zone on your server so that data stored in your databases will by default use the time zone that you have specified.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-change-mysql-server-time-zone\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to change MySQL server time zone"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/5fbfcaed32a2672fb83ab312f5b7237b","name":"InMotion Hosting Contributor","description":"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!","sameAs":["https:\/\/www.linkedin.com\/company\/inmotion-hosting\/","https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/john-paul\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":{"id":4305,"name":"Working with Databases","slug":"databases","link":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/"},"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=473"}],"version-history":[{"count":9,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/473\/revisions"}],"predecessor-version":[{"id":98840,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/473\/revisions\/98840"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}