How to grant full privileges to a user in MySQL

By Dillon Smart · · · 0 Comments

After setting up a lamp stack development environement with phpmyadmin locally on Linux you may notice that your phpmyadmin user (or other user name) doesn’t have the correct privileges to create new databases.

To use the phpmyadmin user to create new databases and users for those databases you need to grant full privileges to the phpmyadmin user, making the user a super user.

First access MySQL via the command line:

sudo mysql -u root

Once your in, run the following command:

GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost';

You should now get a response that looks similar to this:

Query OK, 0 rows affected (0.000 sec)

What you have done is grant the phpmyadmin user full privileges, giving the user the same access as the root user (super user). Typically you should only grant users privilleses on a single database, however as your using a local enviroment and protentially managing multiple databases for multiple projects then it can be more efficient to have a single user (phpmyadmin) to access every database on the fly.

The final step is to flush privileges.

FLUSH PRIVILEGES;

Now you can login to phpmyadmin and your user will have access to all databases and full privileges.

MySQL

0 Comment

Was this helpful? Leave a comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

How to setup a remote MySQL database connection in PHPStorm

Updated 1st October 2023

PHPStorm is packed full of features designed to make the development process for PHP developers efficient and streamlined. Although Jetbrains have a standalone product for interacting with databases, named DataGrip, PHPStrom ships with the Database Tools and SQL plugin. This tools is powerful, integrated directly within the IDE, and provides a convinient way to intract

JDBC Connector Communication link failure error to MySQL

Updated 3rd January 2024

Are you having trouble connecting to a MySQL database through JDBC Connector in a database management tool such as DBeaver Community Edition? DBeaver fails to connect to a local MySQL database with the error “Communication link failure the last packet sent successfully to the server was 0 milliseconds ago“. Here is a breakdown of this

The ULTIMATE guide to setup Windows Subsystem for Linux (WSL) with Ubuntu, Apache2, MySQL and PHP

Updated 16th August 2022

Windows is now good for development! Yes! All thanks to Windows Subsystem for Linux (WSL). No more WAMP or Xampp, WSL can do everything you need. In this ultimate guide to setup Windows Subsystem for Linux with Ubuntu, Apache2, MySQL, and PHP we will cover: What is Windows Subsystem for Linux? Setting up Windows Subsystem