{"id":151,"date":"2026-05-27T23:08:49","date_gmt":"2026-05-28T06:08:49","guid":{"rendered":"https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/"},"modified":"2026-05-27T23:08:49","modified_gmt":"2026-05-28T06:08:49","slug":"fix-mysql-error-1045-access-denied","status":"publish","type":"post","link":"https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/","title":{"rendered":"Fix MySQL Error 1045: Access Denied for User"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>MySQL error 1045 means your connection was refused at the authentication stage. The full message looks like this:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-1\"><code class=\"\" data-line=\"\">ERROR 1045 (28000): Access denied for user &#039;username&#039;@&#039;localhost&#039; (using password: YES)<\/code><\/pre>\n<\/div>\n<p>The frustrating part is that the error is intentionally vague. MySQL won&#8217;t tell you whether the username doesn&#8217;t exist, the password is wrong, or the user simply isn&#8217;t allowed to connect from that host. That&#8217;s by design \u2014 it doesn&#8217;t leak information \u2014 but it makes debugging annoying.<\/p>\n<p>This article covers every common cause of MySQL error 1045: wrong credentials, missing host permissions, plugin mismatches, and socket authentication issues. Whether you&#8217;re running a WordPress site on shared hosting, managing a database on a <a href=\"https:\/\/www.hostandtech.com\/vps-ssd-servers\">VPS SSD Hosting<\/a> plan, or dealing with a misbehaving app on a dedicated server, one of the scenarios below will match your situation.<\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>SSH access to your server (for VPS\/dedicated) or access to cPanel\/WHM<\/li>\n<li>Root or sudo privileges (for resetting passwords or editing MySQL config)<\/li>\n<li>MySQL 5.7+, MySQL 8.0, or MariaDB 10.4+ \u2014 note where behaviour differs<\/li>\n<li>The exact username and hostname from the error message \u2014 copy it precisely<\/li>\n<\/ul>\n<h2>Step-by-Step Instructions<\/h2>\n<h3>Step 1 \u2014 Read the Error Message Carefully<\/h3>\n<p>Before touching anything, look at the hostname in the error. There&#8217;s a big difference between:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-2\"><code class=\"\" data-line=\"\">Access denied for user &#039;myuser&#039;@&#039;localhost&#039;\nAccess denied for user &#039;myuser&#039;@&#039;192.168.1.50&#039;<\/code><\/pre>\n<\/div>\n<p>MySQL treats <code class=\"\" data-line=\"\">localhost<\/code> and <code class=\"\" data-line=\"\">127.0.0.1<\/code> as different hosts in some configurations. A user granted access on <code class=\"\" data-line=\"\">localhost<\/code> may be denied when the app connects via TCP to <code class=\"\" data-line=\"\">127.0.0.1<\/code>. This is a common gotcha that wastes a lot of time.<\/p>\n<h3>Step 2 \u2014 Verify the User Exists and Check Their Host<\/h3>\n<p>Log in as root and run:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-3\"><code class=\"\" data-line=\"\">SELECT user, host, plugin FROM mysql.user WHERE user = &#039;myuser&#039;;<\/code><\/pre>\n<\/div>\n<p>If the user doesn&#8217;t appear at all, it doesn&#8217;t exist \u2014 skip to Step 4 to create it. If it exists but the host column shows <code class=\"\" data-line=\"\">%<\/code> and you&#8217;re connecting from <code class=\"\" data-line=\"\">localhost<\/code>, or vice versa, that&#8217;s your problem.<\/p>\n<p>\ud83d\udcdd Note: In MariaDB 10.4+ and MySQL 8.0, also check the <code class=\"\" data-line=\"\">plugin<\/code> column. If it shows <code class=\"\" data-line=\"\">auth_socket<\/code> or <code class=\"\" data-line=\"\">unix_socket<\/code>, the user authenticates via the OS user \u2014 not a password. Password-based connections will always fail for that account regardless of what password you use.<\/p>\n<h3>Step 3 \u2014 Reset the User&#8217;s Password<\/h3>\n<p>If the user exists but the password is wrong, reset it. For MySQL 8.0:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-4\"><code class=\"\" data-line=\"\">ALTER USER &#039;myuser&#039;@&#039;localhost&#039; IDENTIFIED WITH mysql_native_password BY &#039;NewStrongPassword&#039;;\nFLUSH PRIVILEGES;<\/code><\/pre>\n<\/div>\n<p>For MariaDB 10.4+:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-5\"><code class=\"\" data-line=\"\">ALTER USER &#039;myuser&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;NewStrongPassword&#039;;\nFLUSH PRIVILEGES;<\/code><\/pre>\n<\/div>\n<p>\u26a0 Warning: Replace <code class=\"\" data-line=\"\">NewStrongPassword<\/code> with a real password. Never leave placeholder values in production. Use a password manager to generate something strong.<\/p>\n<h3>Step 4 \u2014 Create the User With Correct Permissions<\/h3>\n<p>If the user doesn&#8217;t exist, create it and grant access to the right database:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-6\"><code class=\"\" data-line=\"\">CREATE USER &#039;myuser&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;StrongPasswordHere&#039;;\nGRANT ALL PRIVILEGES ON mydatabase.* TO &#039;myuser&#039;@&#039;localhost&#039;;\nFLUSH PRIVILEGES;<\/code><\/pre>\n<\/div>\n<p>If the app connects remotely, replace <code class=\"\" data-line=\"\">localhost<\/code> with the actual connecting IP \u2014 for example <code class=\"\" data-line=\"\">&#039;myuser&#039;@&#039;203.0.113.45&#039;<\/code>. Using <code class=\"\" data-line=\"\">&#039;%&#039;<\/code> grants access from any IP, which is convenient but poor practice on production servers.<\/p>\n<h3>Step 5 \u2014 Fix Root Access Issues (Socket Auth)<\/h3>\n<p>On Ubuntu 20.04\/22.04\/24.04 and Debian systems, the MySQL\/MariaDB root user uses socket authentication by default. This means <code class=\"\" data-line=\"\">mysql -u root -p<\/code> fails unless you&#8217;re running the command as the OS root user. This also causes <code class=\"\" data-line=\"\">mysql_secure_installation<\/code> to fail with error 1045.<\/p>\n<p>To switch root to password authentication:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-7\"><code class=\"\" data-line=\"\">sudo mysql<\/code><\/pre>\n<\/div>\n<p>Then inside the MySQL prompt:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-8\"><code class=\"\" data-line=\"\">ALTER USER &#039;root&#039;@&#039;localhost&#039; IDENTIFIED WITH mysql_native_password BY &#039;YourRootPassword&#039;;\nFLUSH PRIVILEGES;\nEXIT;<\/code><\/pre>\n<\/div>\n<p>Now re-run <code class=\"\" data-line=\"\">mysql_secure_installation<\/code> normally:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-9\"><code class=\"\" data-line=\"\">sudo mysql_secure_installation<\/code><\/pre>\n<\/div>\n<p>\ud83d\udcdd Note: On cPanel servers, don&#8217;t manually alter the root MySQL password without updating it in WHM under <strong>Home &gt; SQL Services &gt; MySQL Root Password<\/strong>. If cPanel loses track of the root password, several services break silently.<\/p>\n<h3>Step 6 \u2014 Fix Error 1045 in cPanel<\/h3>\n<p>If you&#8217;re on shared hosting or a cPanel VPS, you can&#8217;t log in as MySQL root directly. Use the cPanel interface:<\/p>\n<ol>\n<li>Log in to cPanel and click <strong>MySQL Databases<\/strong>.<\/li>\n<li>Scroll to <strong>Current Users<\/strong> and click <strong>Change Password<\/strong> next to the affected user.<\/li>\n<li>Update the password and copy it exactly into your app&#8217;s config file (wp-config.php, .env, database.yml, etc.).<\/li>\n<li>Make sure the user is actually assigned to the database \u2014 scroll to <strong>Add User To Database<\/strong> and check.<\/li>\n<\/ol>\n<p>It&#8217;s easy to create a MySQL user in cPanel and forget to add them to the database. The user can exist, the password can be correct, and the connection still fails with error 1045 because no privileges were ever granted.<\/p>\n<h3>Step 7 \u2014 Check Your App&#8217;s Connection Config<\/h3>\n<p>If the credentials look right on the MySQL side, the problem is often in the app config. For WordPress, open <code class=\"\" data-line=\"\">wp-config.php<\/code>:<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-10\"><code class=\"\" data-line=\"\">define( &#039;DB_NAME&#039;,     &#039;your_database_name&#039; );\ndefine( &#039;DB_USER&#039;,     &#039;your_db_user&#039; );\ndefine( &#039;DB_PASSWORD&#039;, &#039;your_db_password&#039; );\ndefine( &#039;DB_HOST&#039;,     &#039;localhost&#039; );<\/code><\/pre>\n<\/div>\n<p>Confirm each value matches exactly what&#8217;s in MySQL. One trailing space or copied quote mark will cause this error.<\/p>\n<p>\ud83d\udcdd Note: If your server uses a MySQL socket instead of TCP, <code class=\"\" data-line=\"\">DB_HOST<\/code> might need to be a socket path like <code class=\"\" data-line=\"\">\/var\/run\/mysqld\/mysqld.sock<\/code> rather than <code class=\"\" data-line=\"\">localhost<\/code>. Check with your hosting provider if you&#8217;re unsure.<\/p>\n<h2>Common Issues and Troubleshooting<\/h2>\n<h3>Password is Correct But Error 1045 Still Appears<\/h3>\n<p>The most likely cause is a host mismatch. MySQL users are defined as <code class=\"\" data-line=\"\">user@host<\/code> pairs. A user created as <code class=\"\" data-line=\"\">myuser@localhost<\/code> is a completely different account from <code class=\"\" data-line=\"\">myuser@127.0.0.1<\/code>. Run the <code class=\"\" data-line=\"\">SELECT user, host FROM mysql.user<\/code> query from Step 2 and confirm the host matches exactly how the app is connecting.<\/p>\n<h3>Error 1045 After Migrating to a New Server<\/h3>\n<p>Database dumps don&#8217;t always include user\/privilege records from the <code class=\"\" data-line=\"\">mysql<\/code> system database. After a migration, databases exist but users may not. Re-create the MySQL users manually on the new server and re-grant privileges. If you used <code class=\"\" data-line=\"\">mysqldump --all-databases<\/code>, it should include the grant tables, but always verify with the <code class=\"\" data-line=\"\">SELECT user, host FROM mysql.user<\/code> check.<\/p>\n<h3>Remote App Getting Error 1045<\/h3>\n<p>If your app is on a separate server (common in multi-server or cloud setups), the MySQL user must be created with the app server&#8217;s IP as the host, not <code class=\"\" data-line=\"\">localhost<\/code>. You also need to make sure MySQL is listening on a non-loopback interface \u2014 check <code class=\"\" data-line=\"\">bind-address<\/code> in <code class=\"\" data-line=\"\">\/etc\/mysql\/mysql.conf.d\/mysqld.cnf<\/code> (Ubuntu) or <code class=\"\" data-line=\"\">\/etc\/my.cnf<\/code> (CentOS\/AlmaLinux). If it&#8217;s set to <code class=\"\" data-line=\"\">127.0.0.1<\/code>, remote connections are blocked at the network level before MySQL even checks credentials.<\/p>\n<div class=\"ht-code-snippet\"><button class=\"ht-code-snippet__copy\" type=\"button\" aria-label=\"Copy code\"><\/button><span class=\"ht-code-snippet__feedback\">Copied to clipboard<\/span><\/p>\n<pre class=\"ht-code-snippet__code\" id=\"code-block-11\"><code class=\"\" data-line=\"\"># Check current bind address\ngrep bind-address \/etc\/mysql\/mysql.conf.d\/mysqld.cnf<\/code><\/pre>\n<\/div>\n<h3>mysql_secure_installation Fails With Error 1045<\/h3>\n<p>This is the socket authentication issue described in Step 5. On Debian\/Ubuntu systems, run <code class=\"\" data-line=\"\">sudo mysql<\/code> first, change root&#8217;s auth plugin to <code class=\"\" data-line=\"\">mysql_native_password<\/code>, flush privileges, exit, then re-run the script. Don&#8217;t skip the <code class=\"\" data-line=\"\">FLUSH PRIVILEGES<\/code> \u2014 without it, the change doesn&#8217;t take effect for the current session.<\/p>\n<h3>Error 1045 in WHM After MySQL Upgrade<\/h3>\n<p>MySQL 8.0 changed the default authentication plugin from <code class=\"\" data-line=\"\">mysql_native_password<\/code> to <code class=\"\" data-line=\"\">caching_sha2_password<\/code>. Some older PHP versions and cPanel-managed services don&#8217;t support <code class=\"\" data-line=\"\">caching_sha2_password<\/code>. After an in-place upgrade, existing apps may break. Check the plugin column in <code class=\"\" data-line=\"\">mysql.user<\/code> for affected accounts and alter them back to <code class=\"\" data-line=\"\">mysql_native_password<\/code> as shown in Step 3. WHM&#8217;s MySQL upgrade wizard sometimes handles this \u2014 but not always.<\/p>\n<h2>FAQ<\/h2>\n<div class=\"ht-faq-section\">\n<h2>Frequently Asked Questions<\/h2>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">What causes MySQL ERROR 1045 Access Denied?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>Error 1045 means MySQL refused the login at the authentication stage. The three most common causes are: the password is wrong, the user doesn&#8217;t exist in mysql.user, or the user exists but isn&#8217;t allowed to connect from the hostname your app is using. MySQL intentionally gives the same error for all three cases so it doesn&#8217;t leak information about which accounts exist.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">How do I reset a MySQL user password without losing data?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>Use ALTER USER \u2014 it changes the password without touching the database or permissions. Run: ALTER USER &#8216;username&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;NewPassword&#8217;; followed by FLUSH PRIVILEGES; The database and all its data stay completely intact. You&#8217;re only changing the authentication credential.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">Why does error 1045 happen even though the password is correct?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>Most likely it&#8217;s a host mismatch. MySQL treats &#8216;user@localhost&#8217; and &#8216;user@127.0.0.1&#8217; as separate accounts. If your app connects via TCP to 127.0.0.1 but the MySQL user was created for localhost, access is denied even with the right password. Check the host value with: SELECT user, host FROM mysql.user WHERE user = &#8216;youruser&#8217;;<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">How do I fix error 1045 in cPanel?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>In cPanel, go to MySQL Databases and check two things: first, that the user&#8217;s password matches what&#8217;s in your app config; second, that the user is actually assigned to the database under &#8216;Add User To Database&#8217;. It&#8217;s easy to create a user and forget the second step \u2014 that alone causes error 1045.<\/p>\n<\/div>\n<\/div>\n<div class=\"ht-faq-item\">\n<h3 class=\"ht-faq-question\">Can I fix MySQL error 1045 without root access?<\/h3>\n<div class=\"ht-faq-answer\">\n<p>If you&#8217;re on shared hosting, you can reset your database user password through cPanel&#8217;s MySQL Databases interface without needing root. On a VPS or dedicated server without root, you&#8217;d need your host to reset the MySQL root password for you. Host &amp; Tech support can assist with this for managed plans.<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>MySQL error 1045 is one of the most common \u2014 and most misdiagnosed \u2014 database errors in hosting. It means the server refused the login, but the cause isn&#8217;t always a wrong password. This guide walks through every real-world scenario and how to fix each one.<\/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":""}},"footnotes":""},"categories":[59],"tags":[225,229,231,228,224,230,226,227],"class_list":["post-151","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-access-denied-mysql","tag-cpanel-mysql","tag-fix-mysql-error-1045-access-denied-for-user","tag-mariadb-access-denied","tag-mysql-error-1045","tag-mysql-error-1045-access-denied","tag-mysql-user-permissions","tag-reset-mysql-password"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Fix MySQL Error 1045: Access Denied for User<\/title>\n<meta name=\"description\" content=\"MySQL error 1045 access denied stopping your app or site? Step-by-step fixes for cPanel, VPS, and dedicated server environments. Works for MySQL 8 and MariaDB.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fix MySQL Error 1045: Access Denied for User\" \/>\n<meta property=\"og:description\" content=\"MySQL error 1045 access denied stopping your app or site? Step-by-step fixes for cPanel, VPS, and dedicated server environments. Works for MySQL 8 and MariaDB.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/\" \/>\n<meta property=\"og:site_name\" content=\"Host And Tech knowledge base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/stshostandtech\" \/>\n<meta property=\"article:published_time\" content=\"2026-05-28T06:08:49+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@stshostandtech\" \/>\n<meta name=\"twitter:site\" content=\"@stshostandtech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/fix-mysql-error-1045-access-denied\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/fix-mysql-error-1045-access-denied\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/person\\\/b6fa79c48ddaba71af32e395c5b017ee\"},\"headline\":\"Fix MySQL Error 1045: Access Denied for User\",\"datePublished\":\"2026-05-28T06:08:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/fix-mysql-error-1045-access-denied\\\/\"},\"wordCount\":1351,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\"},\"keywords\":[\"access denied mysql\",\"cPanel mysql\",\"Fix MySQL Error 1045: Access Denied for User\",\"mariadb access denied\",\"mysql error 1045\",\"MySQL error 1045 access denied\",\"mysql user permissions\",\"reset mysql password\"],\"articleSection\":[\"MySQL &amp; MariaDB\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/fix-mysql-error-1045-access-denied\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/fix-mysql-error-1045-access-denied\\\/\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/fix-mysql-error-1045-access-denied\\\/\",\"name\":\"Fix MySQL Error 1045: Access Denied for User\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#website\"},\"datePublished\":\"2026-05-28T06:08:49+00:00\",\"description\":\"MySQL error 1045 access denied stopping your app or site? Step-by-step fixes for cPanel, VPS, and dedicated server environments. Works for MySQL 8 and MariaDB.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/fix-mysql-error-1045-access-denied\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/fix-mysql-error-1045-access-denied\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/mysql\\\/fix-mysql-error-1045-access-denied\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Fix MySQL Error 1045: Access Denied for User\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\",\"name\":\"Host And Tech knowledge base\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#organization\",\"name\":\"Host And Tech knowledge base\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/logo-dark.png\",\"contentUrl\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/logo-dark.png\",\"width\":1134,\"height\":395,\"caption\":\"Host And Tech knowledge base\"},\"image\":{\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/stshostandtech\",\"https:\\\/\\\/x.com\\\/stshostandtech\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/#\\\/schema\\\/person\\\/b6fa79c48ddaba71af32e395c5b017ee\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\\\/\\\/hostandtech.com\\\/kb\"],\"url\":\"https:\\\/\\\/hostandtech.com\\\/kb\\\/author\\\/admin_fjj7qydm\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fix MySQL Error 1045: Access Denied for User","description":"MySQL error 1045 access denied stopping your app or site? Step-by-step fixes for cPanel, VPS, and dedicated server environments. Works for MySQL 8 and MariaDB.","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:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/","og_locale":"en_US","og_type":"article","og_title":"Fix MySQL Error 1045: Access Denied for User","og_description":"MySQL error 1045 access denied stopping your app or site? Step-by-step fixes for cPanel, VPS, and dedicated server environments. Works for MySQL 8 and MariaDB.","og_url":"https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/","og_site_name":"Host And Tech knowledge base","article_publisher":"https:\/\/www.facebook.com\/stshostandtech","article_published_time":"2026-05-28T06:08:49+00:00","author":"admin","twitter_card":"summary_large_image","twitter_creator":"@stshostandtech","twitter_site":"@stshostandtech","twitter_misc":{"Written by":"admin","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/#article","isPartOf":{"@id":"https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/"},"author":{"name":"admin","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/person\/b6fa79c48ddaba71af32e395c5b017ee"},"headline":"Fix MySQL Error 1045: Access Denied for User","datePublished":"2026-05-28T06:08:49+00:00","mainEntityOfPage":{"@id":"https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/"},"wordCount":1351,"commentCount":0,"publisher":{"@id":"https:\/\/hostandtech.com\/kb\/#organization"},"keywords":["access denied mysql","cPanel mysql","Fix MySQL Error 1045: Access Denied for User","mariadb access denied","mysql error 1045","MySQL error 1045 access denied","mysql user permissions","reset mysql password"],"articleSection":["MySQL &amp; MariaDB"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/","url":"https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/","name":"Fix MySQL Error 1045: Access Denied for User","isPartOf":{"@id":"https:\/\/hostandtech.com\/kb\/#website"},"datePublished":"2026-05-28T06:08:49+00:00","description":"MySQL error 1045 access denied stopping your app or site? Step-by-step fixes for cPanel, VPS, and dedicated server environments. Works for MySQL 8 and MariaDB.","breadcrumb":{"@id":"https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/hostandtech.com\/kb\/mysql\/fix-mysql-error-1045-access-denied\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hostandtech.com\/kb\/"},{"@type":"ListItem","position":2,"name":"Fix MySQL Error 1045: Access Denied for User"}]},{"@type":"WebSite","@id":"https:\/\/hostandtech.com\/kb\/#website","url":"https:\/\/hostandtech.com\/kb\/","name":"Host And Tech knowledge base","description":"","publisher":{"@id":"https:\/\/hostandtech.com\/kb\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hostandtech.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/hostandtech.com\/kb\/#organization","name":"Host And Tech knowledge base","url":"https:\/\/hostandtech.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/hostandtech.com\/kb\/wp-content\/uploads\/2026\/05\/logo-dark.png","contentUrl":"https:\/\/hostandtech.com\/kb\/wp-content\/uploads\/2026\/05\/logo-dark.png","width":1134,"height":395,"caption":"Host And Tech knowledge base"},"image":{"@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/stshostandtech","https:\/\/x.com\/stshostandtech"]},{"@type":"Person","@id":"https:\/\/hostandtech.com\/kb\/#\/schema\/person\/b6fa79c48ddaba71af32e395c5b017ee","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/aa1edac8bbadb442e059a5b65ad45a3b2e3ce689202373b96e3e567517ae4b39?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/hostandtech.com\/kb"],"url":"https:\/\/hostandtech.com\/kb\/author\/admin_fjj7qydm\/"}]}},"_links":{"self":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts\/151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/comments?post=151"}],"version-history":[{"count":0,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/posts\/151\/revisions"}],"wp:attachment":[{"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/media?parent=151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/categories?post=151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostandtech.com\/kb\/wp-json\/wp\/v2\/tags?post=151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}