The first thing to understand is that in previous versions of MySql, you could just use root and the password you set in your configuration of phpMyAdmin. The process has changed and you now use sudo to access MySql/MariaDB on your Raspberry Pi or any current Debian/SQL versions as I understand it.
Creating A phpMyAdmin “root” User
It’s pretty straight forward, create a user that has privileges like root. To launch MySql or MariaDB type the following in terminal. You will be prompted for your password.
sudo mysql
You will now see your DB prompt.
MariaDB [(none)]>
Type the following while changing “chosen_password” to a password you will use to login to phpMyAdmin. This will create a user called phpmyadmin.
CREATE USER 'phpmyadmin'@'%' IDENTIFIED BY 'chosen_password';
Now we grant full access privileges to phpmyadmin.
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
Or if you need to allow remote connections.
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'%' WITH GRANT OPTION;
Next you just need to flush privileges.
FLUSH PRIVILEGES;
You can now type exit or hit ctrl > D to quit and launch phpMyAdmin. Use the username phpmyadmin and your password you just set.
Updating The phpMyAdmin Configuration
Finally, you will need to let phpMyAdmin Know about your user. Run the following to edit the file.
sudo nano /etc/dbconfig-common/phpmyadmin.conf
You will need to locate the following and update the user and password to match what we set above.
# dbc_dbuser: database user # the name of the user who we will use to connect to the database. dbc_dbuser='phpmyadmin' # dbc_dbpass: database user password # the password to use with the above username when connecting # to a database, if one is required dbc_dbpass='chosen_password'
Restart Apache
Run:
sudo service apache2 restart
Conclusion
It’s pretty straight forward and apparently it’s more secure and I’m always happy to have more security.You should be able to see all of your DB’s and manage everything with your new user. Let me know if you have any questions in the comments below.