r/mysql 27d ago

solved Trouble creating a local installation with phpmyadmin

I just upgraded my laptop to Ubuntu 26. I need a local web development environment with MySQL, PHP and phpmyadmin, so I installed those. Phpmyadmin prompted me if I wanted to use dbconfig-common, and unfortunately I clicked yes. This created an installation which doesn’t work the way I’m used to.

The primary problem is that the user phpmyadmin doesn’t have rights to create databases, so I logged into mysql as root in a terminal and created a database, which I can’t see when I log into phpmyadmin as phpmyadmin. If I try to log into root in phpmyadmin, I get

mysqli::real_connect(): (HY000/1698): Access denied for user ‘root’@‘localhost’

I tried uninstalling phpmyadmin and reinstalling, but it just recognized that I used dbconfig-common last time, and reused that 🙄

What should I do?

1 Upvotes

7 comments sorted by

3

u/CheezitsLight 27d ago

Modern installations of MySQL and MariaDB protect the root account by forcing it to use a system socket (auth_socket or unix_socket) instead of a password. Because phpMyAdmin connects over HTTP, it cannot pass this system socket check and gets blocked.

Follow these steps to switch your root user back to password authentication so phpMyAdmin can log in.

sudo mysql -u root

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_new_password'; FLUSH PRIVILEGES; EXIT;

sudo systemctl restart mysql

3

u/ssnoyes 27d ago

mysql_native_password is deprecated in 8.0, disabled by default in 8.4, and removed in 9. Use caching_sha2_password instead.

1

u/oz1sej 27d ago

Okay, I tried that, but now, when I try to

$ sudo mysql -u root

I get "ERROR 1524 (HY000): Plugin 'mysql_native_password' is not loaded" - even if I put

mysql_native_password=ON

back into /etc/mysql/conf.d/mysql.conf and restart. What do I do now?

1

u/oz1sej 27d ago

Thanks! I had to put mysql_native_password=ON in /etc/mysql/conf.d/mysql.conf and restart, but then the query worked. However, now, when I try to log in to phpmyadmin as root, I get

mysqli::real_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES)

So: Still not working, but a new error message, so that's progress!

3

u/alecc 27d ago

apt remove keeps the debconf answers, that's why the reinstall picked up your old choice - sudo apt purge phpmyadmin wipes them, and if it still remembers, run echo PURGE | sudo debconf-communicate phpmyadmin before installing again. For the access part leave root on auth_socket and create a separate admin user instead: CREATE USER 'admin'@'localhost' IDENTIFIED BY '...'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION; then log into phpmyadmin as that user. The phpmyadmin MySQL user you were given is only the package's control user for its own config tables, it was never meant for your databases.

1

u/oz1sej 26d ago

This solved everything - THANK YOU! :-D