{"id":6735,"date":"2021-07-26T10:12:23","date_gmt":"2021-07-26T04:42:23","guid":{"rendered":"https:\/\/www.skynats.com\/?p=6735"},"modified":"2026-02-27T14:04:38","modified_gmt":"2026-02-27T08:34:38","slug":"mysql-error-the-server-requested-authentication-method-unknown-to-the-client","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/mysql-error-the-server-requested-authentication-method-unknown-to-the-client\/","title":{"rendered":"MySQL Error-The server requested an authentication method unknown to the client"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Recently some of our clients got this error when tried to connect the MySQL database. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The main cause for this error is the improper authentication settings given in MySQL.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Why a MySQL authentication plugin?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When a MySQL user tries to login (for example in PhpMyAdmin) then the authentication plugin checks that the connection is whether coming from a legitimate user.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">While creating a user or altering a user using CREATE USER, GRANT, ALTER USER statements you can specify the authentication plugin using IDENTIFIED VIA clause. By default, MariaDB uses the mysql_native_password authentication method in the case without specifying the authentication plugin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Mysql uses also caching_sha2_password and auth_socket plugins for validation. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">MySQL prefers the caching_sha2_password auth method because it uses SHA-2-algorithm with 256 -bit password encryption. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the case of using the auth_socket plugin, it authenticates clients that connect from the localhost through the Unix socket file. This auth_socket plugin checks whether the socket username matches the client program&#8217;s MySQL username to the server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Cause of this Error :<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Some of our users who are using MySQL 8 with PHP 7.0 version got this MySQL authentication unknown error.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By default, MySQL 8 uses the auth_socket MySQL authentication plugin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When trying to access MySQL database using PHP applications (for eg: PhpMyAdmin), it will authenticate the user with the given password. If the authentication plugin type is not changed already it will throw an error message like &#8220;The server requested authentication method unknown to the client&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"672\" height=\"922\" sizes=\"(max-width: 672px) 100vw, 672px\" src=\"https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/07\/87ba712bb79e5a63f10fd51939c751a8.MySQL_the_server_requested_authentication_method_unknown_to_the_client.png\" alt=\"php MyAdmin\" class=\"wp-image-6740\" style=\"width:529px;height:725px\" srcset=\"https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/07\/87ba712bb79e5a63f10fd51939c751a8.MySQL_the_server_requested_authentication_method_unknown_to_the_client.png 672w, https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/07\/87ba712bb79e5a63f10fd51939c751a8.MySQL_the_server_requested_authentication_method_unknown_to_the_client-219x300.png 219w\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Solution :<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In order to fix this issue, you need to change the MySQL authentication plugin type.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For this, you have to log in to the MySQL prompt first.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then run the below command to change the user&#8217;s authentication plugin type ;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ALTER USER 'skynats'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">(Replace skynats and password variable with your username and password details.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, you can change the MySQL authentication method in the my.cnf file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here our my.cnf file is located at \/etc\/my.cnf.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;mysqld]\ndefault_authentication_plugin=mysql_native_password\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then run the below command in the MySQL prompt.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p\n\nmysql &gt; flush privileges;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then you have to restart the MySQL service in the server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>service mysqld restart<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are facing any issue with your MySQL\/ MariaDB no need to worry about it, our <mark style=\"background-color:rgba(0, 0, 0, 0);color:#095cb0\" class=\"has-inline-color\">t<\/mark><mark style=\"background-color:rgba(0, 0, 0, 0);color:#05729d\" class=\"has-inline-color\">echnical team<\/mark><strong><a href=\"https:\/\/www.skynats.com\/contact-us\/\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0);color:#1682ee\" class=\"has-inline-color\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><\/mark><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><\/mark><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-primary-color\"><\/mark><\/mark><\/a><\/strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#bd1e48\" class=\"has-inline-color\"> <\/mark>will handle your database server issue at any time within a short span of time. <em><a href=\"https:\/\/www.skynats.com\/linux-server-management\/\" target=\"_blank\" rel=\"noreferrer noopener\">Contact us<\/a><\/em>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently some of our clients got this error when tried to connect the MySQL database. The main cause for this error is the improper authentication settings given in MySQL. Why a MySQL authentication plugin? When a MySQL user tries to login (for example in PhpMyAdmin) then the authentication plugin checks that the connection is whether [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,257],"tags":[625],"class_list":["post-6735","post","type-post","status-publish","format-standard","hentry","category-blog","category-mysql","tag-server-request-authentication"],"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/6735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=6735"}],"version-history":[{"count":1,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/6735\/revisions"}],"predecessor-version":[{"id":17411,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/6735\/revisions\/17411"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=6735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=6735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=6735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}