{"id":9664,"date":"2025-12-11T11:12:36","date_gmt":"2025-12-11T05:42:36","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=9664"},"modified":"2025-12-11T11:13:08","modified_gmt":"2025-12-11T05:43:08","slug":"how-to-change-mysql-user-authentication-plugin-for-password","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-change-mysql-user-authentication-plugin-for-password\/","title":{"rendered":"How to Change MySQL User Authentication Plugin for Password?"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">MySQL uses <em>authentication plugins<\/em> to verify user identities. Depending on how your server is configured, a user may authenticate with:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>auth_socket<\/code> \u2192 Login without password (Linux system user)<\/li>\n\n\n\n<li><code>mysql_native_password<\/code> \u2192 Old-style MySQL password hashing<\/li>\n\n\n\n<li><code>caching_sha2_password<\/code> \u2192 (Default in MySQL 8) Faster &amp; more secure authentication<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If the wrong plugin is set, users may be unable to log in using a password, especially from applications like <strong>Node.js, PHP, WordPress, Python<\/strong>, etc.<br>This guide shows how to <strong>change the MySQL password authentication plugin<\/strong> manually from the command line (without cPanel).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Login to MySQL as root.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$mysql -u root -p<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check Current Plugin for a User.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$SELECT user, host, plugin FROM mysql.user;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example output:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">user<\/th><th class=\"has-text-align-center\" data-align=\"center\">host<\/th><th class=\"has-text-align-center\" data-align=\"center\">plugin<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">appuser<\/td><td class=\"has-text-align-center\" data-align=\"center\">localhost<\/td><td class=\"has-text-align-center\" data-align=\"center\">auth_socket<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">root<\/td><td class=\"has-text-align-center\" data-align=\"center\">localhost<\/td><td class=\"has-text-align-center\" data-align=\"center\">caching_sha2_password<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Change Auth Plugin (with Usage Examples)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1. Convert user to <code>mysql_native_password<\/code> (for compatibility)<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">This helps when older applications cannot use <code>caching_sha2_password<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$ ALTER USER &#8216;appuser&#8217;@&#8217;localhost&#8217; IDENTIFIED WITH mysql_native_password BY &#8216;StrongPassword@123&#8217;;<br><br>$ FLUSH PRIVILEGES;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Usage Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use when older PHP\/MySQL clients fail to connect.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$ mysql -u appuser -p<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2. Convert user to <code>caching_sha2_password<\/code> (Recommended for MySQL 8)<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$ ALTER USER &#8216;appuser&#8217;@&#8217;localhost&#8217; IDENTIFIED WITH caching_sha2_password BY &#8216;StrongPassword@123&#8217;;<br><br>$ FLUSH PRIVILEGES;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Usage Example with Node.js:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>require(&#8216;mysql2&#8217;).createConnection({<br><br>user: &#8216;appuser&#8217;,<br><br>password: &#8216;StrongPassword@123&#8217;<br><br>});<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>3. Convert user to <code>auth_socket<\/code> (No password required)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Good for local CLI access only.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$ ALTER USER &#8216;appuser&#8217;@&#8217;localhost&#8217; IDENTIFIED WITH auth_socket;<br><br>$ FLUSH PRIVILEGES;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Usage Example:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">User logs using system login (without MySQL password):<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$ sudo mysql -u appuser<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 3: <\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Verify Plugin Change<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>$ SELECT user, host, plugin FROM mysql.user WHERE user=&#8217;appuser&#8217;;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note: <\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">Plugin<\/th><th class=\"has-text-align-left\" data-align=\"left\">Best Use<\/th><\/tr><\/thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><code>caching_sha2_password<\/code><\/td><td class=\"has-text-align-left\" data-align=\"left\">New servers, modern apps<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><code>mysql_native_password<\/code><\/td><td class=\"has-text-align-left\" data-align=\"left\">Legacy apps, WordPress, older PHP<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><code>auth_socket<\/code><\/td><td class=\"has-text-align-left\" data-align=\"left\">Provides automatic MySQL login based on the Linux user account.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Conclusion:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Understanding and modifying MySQL authentication plugins is essential for database security and application compatibility. Newer systems use <code>caching_sha2_password<\/code>, but older systems still rely on <code>mysql_native_password<\/code>. Always choose the plugin that matches application requirements, secure the user\u2019s password, and verify permissions after changes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: MySQL uses authentication plugins to verify user identities. Depending on how your server is configured, a user may authenticate [&hellip;]<\/p>\n","protected":false},"author":496,"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":[1022],"tags":[],"class_list":["post-9664","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-2vS","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/9664","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\/496"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=9664"}],"version-history":[{"count":4,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/9664\/revisions"}],"predecessor-version":[{"id":9669,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/9664\/revisions\/9669"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=9664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=9664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=9664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}