How to Create an Admin User With All Privileges on MariaDB / MySQL

First, login to the server as root.

mysql -u root

If your MySQL / MariaDB installation is not set up to allow you in without a password, add the -p flag.

mysql -u root -p

This will prompt you for your root password. Once you’re in, run this after replacing the variables with your preferred values:

CREATE USER 'admin'@'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

If you want to allow remote connections, use this instead. Keep in mind that this is less secure.

CREATE USER 'admin'@'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

This entry was posted in MySQL / MariaDB. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *