{"id":5555,"date":"2016-11-21T05:41:30","date_gmt":"2016-11-21T05:41:30","guid":{"rendered":"https:\/\/cpanelplesk.com\/wp62\/?p=5555"},"modified":"2021-02-02T05:18:24","modified_gmt":"2021-02-02T05:18:24","slug":"change-default-time-zone-mysql","status":"publish","type":"post","link":"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/","title":{"rendered":"How to change default time zone in MySQL"},"content":{"rendered":"<p><span style=\"color: #000000;\">To change default time zone in MySQL , you must have the root privilege to the server. We have to edit the MySQL configuration file to change the time zone of MySQL server from its default.<\/span><br \/>\n<!--more--><\/p>\n<p><span style=\"color: #000000;\">please note that We can\u2019t change the time zone for a single DB, it\u2019s a global change.<\/span><\/p>\n<p><span style=\"color: #000000;\">By default the MySQL server time is same as the Server time. We can check this by using the following commands:<\/span><\/p>\n<p><span style=\"color: #000000;\">To check the server time<\/span><\/p>\n<div class=\"space1\"><\/div>\n<div class=\"command-sh\">\n<pre>date<\/pre>\n<\/div>\n<div class=\"space1\"><\/div>\n<p><span style=\"color: #000000;\">To check MySQL server time<\/span><\/p>\n<div class=\"space1\"><\/div>\n<div class=\"command-sh\">\n<pre>mysql -e \u201cSELECT NOW();\u201d<\/pre>\n<\/div>\n<div class=\"space1\"><\/div>\n<h2><a href=\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/mysql-default-time\/\" rel=\"attachment wp-att-5557\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-5557 pleslwp\" src=\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2016\/11\/MySQL-default-time.jpg\" alt=\"mysql-default-time\" width=\"484\" height=\"203\" srcset=\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2016\/11\/MySQL-default-time.jpg 484w, https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2016\/11\/MySQL-default-time-300x126.jpg 300w\" sizes=\"(max-width: 484px) 100vw, 484px\" \/><\/a><\/h2>\n<h2><span style=\"color: #000000;\">How to change the MySQL server time from command line:<\/span><\/h2>\n<p><span style=\"color: #000000;\">We can change this by adding the following directives to the MySQL configuration file.<\/span><\/p>\n<ol>\n<li><span style=\"color: #000000;\">\u00a0Log into server as root user.<\/span><\/li>\n<li><span style=\"color: #000000;\">To check MySQL\u2019s current time zone settings, execute the following command:<\/span><\/li>\n<\/ol>\n<div class=\"space1\"><\/div>\n<div class=\"command-sh\">\n<pre>mysql -e \u201cSELECT @@global.time_zone;\u201d<\/pre>\n<\/div>\n<div class=\"space1\"><\/div>\n<p><span style=\"color: #000000;\">It means MySQL is using server SYSTEM default time. To change this, you need to add the following directive into the MySQL conf file.<\/span><\/p>\n<div class=\"space1\"><\/div>\n<div class=\"command-sh\">\n<pre> \u201cdefault-time-zone\u201d<\/pre>\n<\/div>\n<div class=\"space1\"><\/div>\n<p><span style=\"color: #000000;\">1- Open MySQL conf by using your favorite editor;<\/span><\/p>\n<div class=\"space1\"><\/div>\n<div class=\"command-sh\">\n<pre>vi \/etc\/my.cnf\r\n====\r\ndefault-time-zone = '-06:00'\r\n====<\/pre>\n<\/div>\n<div class=\"space1\"><\/div>\n<p><span style=\"color: #000000;\">2- Restart MySQL<\/span><\/p>\n<div class=\"space1\"><\/div>\n<div class=\"command-sh\">\n<pre>service mysql restart<\/pre>\n<\/div>\n<div class=\"space1\"><\/div>\n<p><span style=\"color: #000000;\">That\u2019s it!!! Now check the current MySQL server time by using the command mysql -e <\/span><br \/>\n<span style=\"color: #000000;\">\u201cSELECT NOW();\u201d.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To change default time zone in MySQL , you must have the root privilege to the server. We have to edit the MySQL configuration file to change the time zone of MySQL server from its default. [&#8230;]<\/p>\n<p><a class=\"understrap-read-more-link\" href=\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/\">Continue Reading&#8230;<\/a><\/p>\n","protected":false},"author":2,"featured_media":1585,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5555","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cpanel"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to change default time zone in MySQL - cPanel Plesk<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to change default time zone in MySQL - cPanel Plesk\" \/>\n<meta name=\"twitter:description\" content=\"To change default time zone in MySQL , you must have the root privilege to the server. We have to edit the MySQL configuration file to change the time zone of MySQL server from its default. [...]Continue Reading...\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/02\/timezone.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Seemab Saleem\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/\"},\"author\":{\"name\":\"Seemab Saleem\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648\"},\"headline\":\"How to change default time zone in MySQL\",\"datePublished\":\"2016-11-21T05:41:30+00:00\",\"dateModified\":\"2021-02-02T05:18:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/\"},\"wordCount\":189,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\"},\"image\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/02\/timezone.jpg\",\"articleSection\":[\"Cpanel\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/\",\"name\":\"How to change default time zone in MySQL - cPanel Plesk\",\"isPartOf\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/02\/timezone.jpg\",\"datePublished\":\"2016-11-21T05:41:30+00:00\",\"dateModified\":\"2021-02-02T05:18:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#primaryimage\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/02\/timezone.jpg\",\"contentUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/02\/timezone.jpg\",\"width\":288,\"height\":175},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cpanelplesk.com\/wp62\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to change default time zone in MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#website\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/\",\"name\":\"cPanel Plesk\",\"description\":\"Blog on famous hosting control panels\",\"publisher\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cpanelplesk.com\/wp62\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13\",\"name\":\"Farooq Omer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png\",\"contentUrl\":\"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png\",\"width\":300,\"height\":44,\"caption\":\"Farooq Omer\"},\"logo\":{\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648\",\"name\":\"Seemab Saleem\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g\",\"caption\":\"Seemab Saleem\"},\"description\":\"Linux Server Administrator, Web Hosting engineer. I'm dealing with Linux servers since 2014. I started this blog to share the work i love with the world . let me know if you need any assistance. Thanks!!\",\"sameAs\":[\"https:\/\/cpanelplesk.com\/wp62\"],\"url\":\"https:\/\/cpanelplesk.com\/wp62\/author\/cmb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to change default time zone in MySQL - cPanel Plesk","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:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/","twitter_card":"summary_large_image","twitter_title":"How to change default time zone in MySQL - cPanel Plesk","twitter_description":"To change default time zone in MySQL , you must have the root privilege to the server. We have to edit the MySQL configuration file to change the time zone of MySQL server from its default. [...]Continue Reading...","twitter_image":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/02\/timezone.jpg","twitter_misc":{"Written by":"Seemab Saleem","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#article","isPartOf":{"@id":"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/"},"author":{"name":"Seemab Saleem","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648"},"headline":"How to change default time zone in MySQL","datePublished":"2016-11-21T05:41:30+00:00","dateModified":"2021-02-02T05:18:24+00:00","mainEntityOfPage":{"@id":"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/"},"wordCount":189,"commentCount":1,"publisher":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13"},"image":{"@id":"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/02\/timezone.jpg","articleSection":["Cpanel"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/","url":"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/","name":"How to change default time zone in MySQL - cPanel Plesk","isPartOf":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#primaryimage"},"image":{"@id":"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/02\/timezone.jpg","datePublished":"2016-11-21T05:41:30+00:00","dateModified":"2021-02-02T05:18:24+00:00","breadcrumb":{"@id":"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#primaryimage","url":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/02\/timezone.jpg","contentUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2015\/02\/timezone.jpg","width":288,"height":175},{"@type":"BreadcrumbList","@id":"https:\/\/cpanelplesk.com\/wp62\/change-default-time-zone-mysql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cpanelplesk.com\/wp62\/"},{"@type":"ListItem","position":2,"name":"How to change default time zone in MySQL"}]},{"@type":"WebSite","@id":"https:\/\/cpanelplesk.com\/wp62\/#website","url":"https:\/\/cpanelplesk.com\/wp62\/","name":"cPanel Plesk","description":"Blog on famous hosting control panels","publisher":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cpanelplesk.com\/wp62\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/c78ae1cf9451a09592fb9697d69c0c13","name":"Farooq Omer","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/","url":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png","contentUrl":"https:\/\/cpanelplesk.com\/wp62\/wp-content\/uploads\/2020\/11\/cpanelplesk.png","width":300,"height":44,"caption":"Farooq Omer"},"logo":{"@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/"}},{"@type":"Person","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/73d573cc7eaaf6625cf0dbd72191a648","name":"Seemab Saleem","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cpanelplesk.com\/wp62\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6a87ff2e53b03e6839250e5278a6bd46?s=96&d=mm&r=g","caption":"Seemab Saleem"},"description":"Linux Server Administrator, Web Hosting engineer. I'm dealing with Linux servers since 2014. I started this blog to share the work i love with the world . let me know if you need any assistance. Thanks!!","sameAs":["https:\/\/cpanelplesk.com\/wp62"],"url":"https:\/\/cpanelplesk.com\/wp62\/author\/cmb\/"}]}},"_links":{"self":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/5555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/comments?post=5555"}],"version-history":[{"count":0,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/posts\/5555\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/media\/1585"}],"wp:attachment":[{"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/media?parent=5555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/categories?post=5555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelplesk.com\/wp62\/wp-json\/wp\/v2\/tags?post=5555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}