{"id":2276,"date":"2018-05-05T13:42:23","date_gmt":"2018-05-05T08:12:23","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=2276"},"modified":"2018-05-05T13:42:23","modified_gmt":"2018-05-05T08:12:23","slug":"change-mysql-data-directory-on-cpanel-safely-move-mysql-data-directory-centos","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/change-mysql-data-directory-on-cpanel-safely-move-mysql-data-directory-centos\/","title":{"rendered":"Change mysql data directory on cPanel| Safely move mysql data directory  &#8211; Centos"},"content":{"rendered":"<h3>Change mysql data directory on cPanel| Safely move mysql data directory &#8211; Centos<\/h3>\n<p><strong>Date Posted: 05-05-2018<\/strong><\/p>\n<p>This post explains on how to move or setup different data directory for mysql application. If there is no database exists, skip the first step. This post deals with moving data directory to \/home\/mysql<\/p>\n<p>Create an existing data directory in a tar file. The default data directory for mysql is\u00a0<em>\/var\/lib\/mysql<\/em><\/p>\n<p><code>tar -cvf mysql.tar \/var\/lib\/mysql<\/code><\/p>\n<p>Create the directory \/home\/mysql<\/p>\n<p><code>mkdir -p \/home\/mysql<\/code><\/p>\n<p>Now, rsync the data directory from \/var\/lib\/mysql to \/home\/mysql. If the data directory is huge then we recommend to run rsync process in screen<\/p>\n<p><code>screen -S rsync<\/code><\/p>\n<p><code>rsync -avp \/var\/lib\/mysql\/ \/home\/mysql<\/code><\/p>\n<p>Press\u00a0<strong>Ctrl + A +\u00a0 D\u00a0<\/strong>to come out of screen<\/p>\n<p>Depends on the size of the directory , it may take little while.\u00a0 Now, open the screen and view the progress state.<\/p>\n<p><code>screen -ls<\/code><\/p>\n<p><code>screen -x screenID<\/code><\/p>\n<p>Now, stop the mysql service.<\/p>\n<p><code>\/etc\/init.d\/mysql stop<\/code><\/p>\n<p>Initiate the rsync process again to copy the data directory.<\/p>\n<p><code>rsync -avp --delete \/var\/lib\/mysql\/ \/home\/mysql\/<\/code><\/p>\n<p>Change the permission of new data directory with mysql<\/p>\n<p><code>chown -R mysql.mysql \/home\/mysql<\/code><\/p>\n<p>Edit the mysql configuration with new data directory(\/etc\/my.cnf)<\/p>\n<p><code>vi \/etc\/my.cnf<\/code><\/p>\n<blockquote><p>datadirectory=\/home\/mysql<\/p><\/blockquote>\n<p>Now, start the mysql service.<\/p>\n<p><code>\/etc\/init.d\/mysql start<\/code><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Change mysql data directory on cPanel| Safely move mysql data directory &#8211; Centos Date Posted: 05-05-2018 This post explains on [&hellip;]<\/p>\n","protected":false},"author":1,"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":[1019],"tags":[263,261,179],"class_list":["post-2276","post","type-post","status-publish","format-standard","hentry","category-cloud-aws","tag-cpanel","tag-linux","tag-mysql-2","psol-cat-cloud-aws"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-AI","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2276","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=2276"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2276\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}