{"id":3737,"date":"2016-05-03T08:36:27","date_gmt":"2016-05-03T12:36:27","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2016\/05\/03\/how-to-upgrade-mysql-on-centos\/"},"modified":"2021-08-16T22:49:41","modified_gmt":"2021-08-17T02:49:41","slug":"how-to-upgrade-mysql-on-centos","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/","title":{"rendered":"How to Upgrade MySQL on CentOS"},"content":{"rendered":"<p>This guide will go over how to upgrade the MySQL version on your <a href=\"https:\/\/www.inmotionhosting.com\/dedicated-servers\">dedicated server<\/a>. This requires you to be logged into the server command line as the root user. Please follow all of the steps very carefully as you can easily corrupt your databases if this upgrade is not done properly. Also, please remember to keep updated backups of your databases prior to upgrading.<\/p>\n<p class=\"alert alert-danger\"><i><strong>NOTE:<\/strong> <a href=\"\/support\/amp\/obtain-root-access\/\">Root access<\/a> is required to upgrade MySQL.<\/i><\/p>\n<h2>Creating a Back Up &amp; Upgrading<\/h2>\n<ol class=\"article_list\">\n<li><a href=\"\/support\/server\/ssh\/how-to-login-ssh\/\">Log into your server via SSH<\/a> with the root user.\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<li>Create a directory to store the backups and list the databases that have been backed up.\n<div class=\"cli\"><span style=\"color: red;\">mkdir \/root\/dbbackups; touch \/root\/dbbackups\/list <\/span><\/div>\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<li>Next, backup the databases. It\u2019s okay if you get a SELECT and LOCK error on certain tables relating to the schema databases.\n<div class=\"cli\"><span style=\"color: red;\">for db in $( mysql -e \u2018show databases\u2019 | grep -v \u201cDatabase\\|information_schema\u201d | awk \u2018{print $1}\u2019 ) ; do mysqldump \u2013add-drop-table $db &gt; \/root\/dbbackups\/$db.sql &amp;&amp; echo $db &gt;&gt; \/root\/dbbackups\/list; done <\/span><\/div>\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<li>Edit the <strong>\/var\/cpanel\/cpanel.config<\/strong> file with your favorite editor (nano, vim, vi, etc). In this example, we\u2019ll use vim\n<div class=\"cli\"><span style=\"color: red;\">vim \/var\/cpanel\/cpanel.config <\/span><\/div>\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<li><a href=\"\/support\/images\/stories\/product-guides\/dedicated\/upgrade-mysql\/step5.jpg\" rel=\"lightbox-0\"><img decoding=\"async\" class=\"std_ss\" style=\"float: right; margin: 0px 15px 15px 15px;\" title=\"Click here to view the larger image\" src=\"\/support\/images\/stories\/product-guides\/dedicated\/upgrade-mysql\/step5.jpg\" alt=\"\" width=\"200\"><\/a>\n<div style=\"clear: both;\"><\/div>\n<p>Perform a search for <strong>mysql-version<\/strong> (default is around line 180) and edit it to the desired version.<\/p>\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<li>Save the file and run the following command for cPanel to upgrade or downgrade your MySQL version.\n<div class=\"cli\"><span style=\"color: red;\">\/usr\/local\/cpanel\/scripts\/check_cpanel_rpms \u2013fix<\/span><\/div>\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<li>Once the script is complete and there are no errors saying it failed, proceed to log into the MySQL command interface and you should see the following. In this tutorial we went from 5.6 to 5.5 in order to demonstrate\n<div class=\"cli\"><span style=\"color: red;\">mysql -u root<\/span><br>\nWelcome to the MySQL monitor. Commands end with ; or \\g.<br>\nYour MySQL connection id is 11<br>\nServer version: 5.5.49-cll MySQL Community Server (GPL)\n<p>Copyright (c) 2000, 2016, Oracle and\/or its affiliates. All rights reserved.<\/p>\n<p>Oracle is a registered trademark of Oracle Corporation and\/or its<br>\naffiliates. Other names may be trademarks of their respective owners.<\/p>\n<p>Type \u2018help;\u2019 or \u2018\\h\u2019 for help. Type \u2018\\c\u2019 to clear the current input statement.<\/p>\n<p>mysql&gt;<\/p>\n<\/div>\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<li>Just to be on the safe side you may want to repair the databases as a preventative measure.\n<div class=\"cli\"><span style=\"color: red;\">mysqlcheck -aR<\/span><\/div>\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<li>Also, you should run the following command to upgrade the system tables so there are no issues.\n<div class=\"cli\"><span style=\"color: red;\">mysql_upgrade<\/span><\/div>\n<div style=\"clear: both;\"><\/div>\n<\/li>\n<\/ol>\n<p>If you need to restore the databases you have previously backed up then you can do so via the following command.<\/p>\n<div class=\"cli\"><span style=\"color: red;\">for db in `cat \/root\/dbbackups\/list` ; do mysql $db &lt; \/root\/dbbackups\/$db.sql ; done <\/span><\/div>\n<p>You can use <a href=\"\/support\/edu\/easyapache\/upgrade-php-easyapache\/\">EasyApache within WHM to recompile PHP<\/a>, since it is usually necessary due to the MySQL changes 90% of the time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide will go over how to upgrade the MySQL version on your dedicated server. This requires you to be logged into the server command line as the root user. Please follow all of the steps very carefully as you can easily corrupt your databases if this upgrade is not done properly. Also, please remember<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/\"> Read More ><\/a><\/p>\n","protected":false},"author":57014,"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-3737","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 Upgrade MySQL on CentOS | InMotion Hosting<\/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:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Upgrade MySQL on CentOS | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"This guide will go over how to upgrade the MySQL version on your dedicated server. This requires you to be logged into the server command line as the root user. Please follow all of the steps very carefully as you can easily corrupt your databases if this upgrade is not done properly. Also, please remember Read More &gt;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/\" \/>\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=\"2016-05-03T12:36:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-17T02:49:41+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=\"2 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-upgrade-mysql-on-centos\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/\"},\"author\":{\"name\":\"InMotion Hosting Contributor\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\"},\"headline\":\"How to Upgrade MySQL on CentOS\",\"datePublished\":\"2016-05-03T12:36:27+00:00\",\"dateModified\":\"2021-08-17T02:49:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/\"},\"wordCount\":450,\"commentCount\":0,\"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-upgrade-mysql-on-centos\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/\",\"name\":\"How to Upgrade MySQL on CentOS | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2016-05-03T12:36:27+00:00\",\"dateModified\":\"2021-08-17T02:49:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Upgrade MySQL on CentOS\"}]},{\"@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\/f9a4fc454cd1df128ee8e898d30d4644\",\"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\/inmotion-hosting-contributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Upgrade MySQL on CentOS | InMotion Hosting","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-upgrade-mysql-on-centos\/","og_locale":"en_US","og_type":"article","og_title":"How to Upgrade MySQL on CentOS | InMotion Hosting","og_description":"This guide will go over how to upgrade the MySQL version on your dedicated server. This requires you to be logged into the server command line as the root user. Please follow all of the steps very carefully as you can easily corrupt your databases if this upgrade is not done properly. Also, please remember Read More >","og_url":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2016-05-03T12:36:27+00:00","article_modified_time":"2021-08-17T02:49:41+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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/"},"author":{"name":"InMotion Hosting Contributor","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644"},"headline":"How to Upgrade MySQL on CentOS","datePublished":"2016-05-03T12:36:27+00:00","dateModified":"2021-08-17T02:49:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/"},"wordCount":450,"commentCount":0,"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-upgrade-mysql-on-centos\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/","url":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/","name":"How to Upgrade MySQL on CentOS | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2016-05-03T12:36:27+00:00","dateModified":"2021-08-17T02:49:41+00:00","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-upgrade-mysql-on-centos\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Upgrade MySQL on CentOS"}]},{"@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\/f9a4fc454cd1df128ee8e898d30d4644","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\/inmotion-hosting-contributor\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3737","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\/57014"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=3737"}],"version-history":[{"count":2,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3737\/revisions"}],"predecessor-version":[{"id":84008,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3737\/revisions\/84008"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=3737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=3737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=3737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}