How to Fix phpMyAdmin Access Denied Errors
DodaTech
Updated 2026-06-24
2 min read
In this tutorial, you'll learn about How to Fix phpMyAdmin Access Denied Errors. We cover key concepts, practical examples, and best practices.
The Problem
phpMyAdmin shows:
#1045 - Access denied for user 'root'@'localhost' (using password: YES)
or:
#1698 - Access denied for user 'root'@'localhost'
Quick Fix
Step 1: Reset the MySQL root password
# Stop MySQL/MariaDB:
systemctl stop mysql
# Start in safe mode:
mysqld_safe --skip-grant-tables &
# Connect without password:
mysql -u root
# Reset password:
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
FLUSH PRIVILEGES;
EXIT;
Step 2: Fix auth_socket to mysql_native_password
# If you get #1698, the root user uses auth_socket:
mysql -u root
# Check the plugin:
SELECT user, plugin, host FROM mysql.user WHERE user='root';
# Change to mysql_native_password:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';
FLUSH PRIVILEGES;
Step 3: Update phpMyAdmin config
Edit /usr/share/phpmyadmin/config.inc.php:
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'new_password';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
Step 4: Create a dedicated phpMyAdmin user
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Step 5: Check web server configuration
# For Apache:
cat /etc/apache2/conf-available/phpmyadmin.conf
# Restart:
systemctl restart apache2
Step 6: Clear phpMyAdmin session files
rm -rf /var/lib/phpmyadmin/tmp/*
Prevention
- Use
mysql_native_passwordfor phpMyAdmin users. - Create a dedicated phpMyAdmin user instead of using root.
- Keep phpMyAdmin updated for security patches.
Common Mistakes with access denied
- Mixing let bindings with <- bindings in do notation, producing type errors
- Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
These mistakes appear frequently in real-world PHPMYADMIN code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
← Previous
How to Fix PHP Variadic Function Argument Errors
Next →
Pinecone Index Creation Rate Limit
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro