Upon installing mariadb in Ubuntu. Some initial configuration must be done to make it a secure server:
- You can set a password for root accounts.
- You can remove root accounts that are accessible from outside the local host.
- You can remove anonymous-user accounts.
- You can remove the test database, which by default can be accessed by anonymous users.
They provide us a script to that do these things automatically.
$sudo mysql_secure_installation
Upon running this script root can only login using sudo. in other words,
$ mysql -u root -p
works only when used with sudo.
To enable all users to login the following steps must be provided.
DROP USER 'root'@'%';
+------+-----------+
| User | Host |
+------+-----------+
| root | localhost |
+------+-----------+
DROP USER 'root'@'localhost';
CREATE USER 'root'@'localhost' IDENTIFIED BY '123';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost';
FLUSH PRIVILEGES;