Posted over 3 years ago. Visible to the public.

How to add a user with all privileges to MariaDB

Replace newuser with your desired username:

Copy
mysql -uroot -p CREATE USER 'newuser'@'localhost' IDENTIFIED BY ''; GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; FLUSH PRIVILEGES; exit;

Remove password from an existing user

If you already have a user with sufficient privileges but protected by a password, you can remove the password.
Replace existinguser with your desired username:

Copy
mysql -uroot -p SET PASSWORD FOR existinguser@localhost=''; FLUSH PRIVILEGES; exit;

Add a user with unix socket authentication

The mysql client will use the underlying operating system credentials of your user account. You don't have to enter a password.

Replace newuser with the username of your account:

Copy
whoami newuser mysql -uroot -p DROP USER IF EXISTS 'newuser'@'localhost'; CREATE USER 'newuser'@'localhost' IDENTIFIED VIA unix_socket; GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; FLUSH PRIVILEGES; exit;

Add a user with password

Replace newuser with your desired username:

Copy
mysql -uroot -p CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'changeme'; GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost'; FLUSH PRIVILEGES; exit;

If you don't have a user with the sufficient access rights, follow these steps to reset the password.

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Emanuel De
Last edit:
5 months ago
by Andreas Vöst
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Emanuel De to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more