{"id":369,"date":"2010-09-11T02:02:32","date_gmt":"2010-09-11T08:02:32","guid":{"rendered":"http:\/\/blog.supportpro.com\/2010\/09\/change-mysql-data-directory\/"},"modified":"2018-10-04T06:30:28","modified_gmt":"2018-10-04T12:30:28","slug":"change-mysql-data-directory","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/","title":{"rendered":"Change mysql data directory"},"content":{"rendered":"<p>The default location is \/var\/lib\/mysql<br \/>\nYou can change mysql data directory by adding the following entries in \/etc\/my.cnf file<br \/>\ndatadir=newlocation\/path<br \/>\nsave the file, move the necessary database files from \/var\/lib\/mysql to the new location and restart mysql.<\/p>\n<p>&nbsp;<\/p>\n<p><!--more--><\/p>\n<p>To check if the new location is added correctly, login to mysql as root and create a test database and check the new location if the new database files are added or not.<br \/>\nIf mysql doesnt start after restarting then check the logs for an error<br \/>\n# tail -f \/var\/log\/mysqld.log<br \/>\nIf there are no specific errors mentioned check if selinux is enabled or not. If its enabled then you may disable it and try starting mysql.<br \/>\ncommands to check if selinux is enabled<br \/>\n#getenforce<br \/>\nthe result will be like enabled, permissive or targeted You can disable it by editing the configuration file \/etc\/selinux\/config (RHEL\/centos)<\/p>\n<p>If you require help, <a href=\"https:\/\/www.supportpro.com\/requestquote.php\">contact SupportPRO Server Admin<\/a><\/p>\n<p style=\"text-align: center;\"><!--HubSpot Call-to-Action Code --><span id=\"hs-cta-wrapper-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-wrapper\"><span id=\"hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-node hs-cta-9d590242-d641-4383-94b4-8cfd62f0af6b\"><!-- [if lte IE 8]><\/p>\n\n\n\n\n\n<div id=\"hs-cta-ie-element\"><\/div>\n\n\n<![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b\"><img decoding=\"async\" id=\"hs-cta-img-9d590242-d641-4383-94b4-8cfd62f0af6b\" class=\"hs-cta-img\" style=\"border-width: 0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b.png\" alt=\"Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value\" \/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '9d590242-d641-4383-94b4-8cfd62f0af6b', {}); <\/script><\/span><!-- end HubSpot Call-to-Action Code --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The default location is \/var\/lib\/mysql You can change mysql data directory by adding the following entries in \/etc\/my.cnf file datadir=newlocation\/path save the file, move the necessary database files from \/var\/lib\/mysql&hellip;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-369","post","type-post","status-publish","format-standard","hentry","category-miscellaneous"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO Pro 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"The default location is \/var\/lib\/mysql You can change mysql data directory by adding the following entries in \/etc\/my.cnf file datadir=newlocation\/path save the file, move the necessary database files from \/var\/lib\/mysql to the new location and restart mysql. To check if the new location is added correctly, login to mysql as root and create a\" \/>\n\t<meta name=\"robots\" content=\"max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n\t<meta name=\"author\" content=\"SupportPRO Admin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO Pro (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Server Management Tips | SupportPRO Blog\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Change mysql data directory | Server Management Tips\" \/>\n\t\t<meta property=\"og:description\" content=\"The default location is \/var\/lib\/mysql You can change mysql data directory by adding the following entries in \/etc\/my.cnf file datadir=newlocation\/path save the file, move the necessary database files from \/var\/lib\/mysql to the new location and restart mysql. To check if the new location is added correctly, login to mysql as root and create a\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2010-09-11T08:02:32+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2018-10-04T12:30:28+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Change mysql data directory | Server Management Tips\" \/>\n\t\t<meta name=\"twitter:description\" content=\"The default location is \/var\/lib\/mysql You can change mysql data directory by adding the following entries in \/etc\/my.cnf file datadir=newlocation\/path save the file, move the necessary database files from \/var\/lib\/mysql to the new location and restart mysql. To check if the new location is added correctly, login to mysql as root and create a\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/change-mysql-data-directory\\\/#article\",\"name\":\"Change mysql data directory | Server Management Tips\",\"headline\":\"Change mysql data directory\",\"author\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/author\\\/managementadmin\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/no-cache.hubspot.com\\\/cta\\\/default\\\/2725694\\\/9d590242-d641-4383-94b4-8cfd62f0af6b.png\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/change-mysql-data-directory\\\/#articleImage\"},\"datePublished\":\"2010-09-11T02:02:32-06:00\",\"dateModified\":\"2018-10-04T06:30:28-06:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/change-mysql-data-directory\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/change-mysql-data-directory\\\/#webpage\"},\"articleSection\":\"Miscellaneous\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/change-mysql-data-directory\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.supportpro.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/category\\\/miscellaneous\\\/#listItem\",\"name\":\"Miscellaneous\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/category\\\/miscellaneous\\\/#listItem\",\"position\":2,\"name\":\"Miscellaneous\",\"item\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/category\\\/miscellaneous\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/change-mysql-data-directory\\\/#listItem\",\"name\":\"Change mysql data directory\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/change-mysql-data-directory\\\/#listItem\",\"position\":3,\"name\":\"Change mysql data directory\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/category\\\/miscellaneous\\\/#listItem\",\"name\":\"Miscellaneous\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/#organization\",\"name\":\"SupportPRO\",\"description\":\"SupportPRO Blog\",\"url\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/\",\"telephone\":\"+18476076123\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/author\\\/managementadmin\\\/#author\",\"url\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/author\\\/managementadmin\\\/\",\"name\":\"SupportPRO Admin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/change-mysql-data-directory\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/13d2f63048d631e03a432375448be5eb7861069df4fef10f0cb1c7b36554c225?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"SupportPRO Admin\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/change-mysql-data-directory\\\/#webpage\",\"url\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/change-mysql-data-directory\\\/\",\"name\":\"Change mysql data directory | Server Management Tips\",\"description\":\"The default location is \\\/var\\\/lib\\\/mysql You can change mysql data directory by adding the following entries in \\\/etc\\\/my.cnf file datadir=newlocation\\\/path save the file, move the necessary database files from \\\/var\\\/lib\\\/mysql to the new location and restart mysql. To check if the new location is added correctly, login to mysql as root and create a\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/change-mysql-data-directory\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/author\\\/managementadmin\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/author\\\/managementadmin\\\/#author\"},\"datePublished\":\"2010-09-11T02:02:32-06:00\",\"dateModified\":\"2018-10-04T06:30:28-06:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/\",\"name\":\"Server Management Tips\",\"description\":\"SupportPRO Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.supportpro.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO Pro -->\r\n\t\t<title>Change mysql data directory | Server Management Tips<\/title>\n\n","aioseo_head_json":{"title":"Change mysql data directory | Server Management Tips","description":"The default location is \/var\/lib\/mysql You can change mysql data directory by adding the following entries in \/etc\/my.cnf file datadir=newlocation\/path save the file, move the necessary database files from \/var\/lib\/mysql to the new location and restart mysql. To check if the new location is added correctly, login to mysql as root and create a","canonical_url":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/","robots":"max-snippet:-1, max-image-preview:large, max-video-preview:-1","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/#article","name":"Change mysql data directory | Server Management Tips","headline":"Change mysql data directory","author":{"@id":"https:\/\/www.supportpro.com\/blog\/author\/managementadmin\/#author"},"publisher":{"@id":"https:\/\/www.supportpro.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/9d590242-d641-4383-94b4-8cfd62f0af6b.png","@id":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/#articleImage"},"datePublished":"2010-09-11T02:02:32-06:00","dateModified":"2018-10-04T06:30:28-06:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/#webpage"},"isPartOf":{"@id":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/#webpage"},"articleSection":"Miscellaneous"},{"@type":"BreadcrumbList","@id":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.supportpro.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog\/category\/miscellaneous\/#listItem","name":"Miscellaneous"}},{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog\/category\/miscellaneous\/#listItem","position":2,"name":"Miscellaneous","item":"https:\/\/www.supportpro.com\/blog\/category\/miscellaneous\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/#listItem","name":"Change mysql data directory"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/#listItem","position":3,"name":"Change mysql data directory","previousItem":{"@type":"ListItem","@id":"https:\/\/www.supportpro.com\/blog\/category\/miscellaneous\/#listItem","name":"Miscellaneous"}}]},{"@type":"Organization","@id":"https:\/\/www.supportpro.com\/blog\/#organization","name":"SupportPRO","description":"SupportPRO Blog","url":"https:\/\/www.supportpro.com\/blog\/","telephone":"+18476076123"},{"@type":"Person","@id":"https:\/\/www.supportpro.com\/blog\/author\/managementadmin\/#author","url":"https:\/\/www.supportpro.com\/blog\/author\/managementadmin\/","name":"SupportPRO Admin","image":{"@type":"ImageObject","@id":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/13d2f63048d631e03a432375448be5eb7861069df4fef10f0cb1c7b36554c225?s=96&d=mm&r=g","width":96,"height":96,"caption":"SupportPRO Admin"}},{"@type":"WebPage","@id":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/#webpage","url":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/","name":"Change mysql data directory | Server Management Tips","description":"The default location is \/var\/lib\/mysql You can change mysql data directory by adding the following entries in \/etc\/my.cnf file datadir=newlocation\/path save the file, move the necessary database files from \/var\/lib\/mysql to the new location and restart mysql. To check if the new location is added correctly, login to mysql as root and create a","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.supportpro.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/#breadcrumblist"},"author":{"@id":"https:\/\/www.supportpro.com\/blog\/author\/managementadmin\/#author"},"creator":{"@id":"https:\/\/www.supportpro.com\/blog\/author\/managementadmin\/#author"},"datePublished":"2010-09-11T02:02:32-06:00","dateModified":"2018-10-04T06:30:28-06:00"},{"@type":"WebSite","@id":"https:\/\/www.supportpro.com\/blog\/#website","url":"https:\/\/www.supportpro.com\/blog\/","name":"Server Management Tips","description":"SupportPRO Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.supportpro.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Server Management Tips | SupportPRO Blog","og:type":"article","og:title":"Change mysql data directory | Server Management Tips","og:description":"The default location is \/var\/lib\/mysql You can change mysql data directory by adding the following entries in \/etc\/my.cnf file datadir=newlocation\/path save the file, move the necessary database files from \/var\/lib\/mysql to the new location and restart mysql. To check if the new location is added correctly, login to mysql as root and create a","og:url":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/","article:published_time":"2010-09-11T08:02:32+00:00","article:modified_time":"2018-10-04T12:30:28+00:00","twitter:card":"summary","twitter:title":"Change mysql data directory | Server Management Tips","twitter:description":"The default location is \/var\/lib\/mysql You can change mysql data directory by adding the following entries in \/etc\/my.cnf file datadir=newlocation\/path save the file, move the necessary database files from \/var\/lib\/mysql to the new location and restart mysql. To check if the new location is added correctly, login to mysql as root and create a"},"aioseo_meta_data":{"post_id":"369","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-06-17 11:27:05","breadcrumb_settings":null,"limit_modified_date":false,"open_ai":null,"ai":null,"created":"2021-12-10 16:09:58","updated":"2026-06-30 23:09:09"},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t<a href=\"https:\/\/www.supportpro.com\/blog\" title=\"Home\">Home<\/a>\n<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t<a href=\"https:\/\/www.supportpro.com\/blog\/category\/miscellaneous\/\" title=\"Miscellaneous\">Miscellaneous<\/a>\n<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\tChange mysql data directory\n<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.supportpro.com\/blog"},{"label":"Miscellaneous","link":"https:\/\/www.supportpro.com\/blog\/category\/miscellaneous\/"},{"label":"Change mysql data directory","link":"https:\/\/www.supportpro.com\/blog\/change-mysql-data-directory\/"}],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=369"}],"version-history":[{"count":1,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/369\/revisions"}],"predecessor-version":[{"id":3375,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/369\/revisions\/3375"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}