Linux: Setting up MYSQL server database administration

As it is set up, the root user is all-powerful and automatically used in MariaDB when executing mysql as root. This becomes problematic when trying to access the database through a web-based system such as Adminer.

Therefore, let these be the Commandments of setting up MySQL database users. Thou shalt:

  • keep the root user passwordless and use the root@localhost db user only when accessing MySQL from the command-line.
  • establish a second administrative user with a random name and random password and grant all privileges to that user. For example, by typing CREATE USER 'examplerandomusername'@'localhost' IDENTIFIED BY 'examplerandompassword'; and then GRANT ALL PRIVILEGES ON *.* TO 'examplerandomusername'@'localhost'; FLUSH PRIVILEGES;
  • use a different random username and password with privileges for each database.
4 / 2021