MariaDB user beheer

Docent uitwerking

Geschreven door Peter van Gemert

Op 23 november 2023


  databaseserver $ mysql -u admin_pgt -p
  
  databaseserver mariadb > SHOW DATABASES;
  databaseserver mariadb > USE datacenter;
  databaseserver mariadb > SHOW TABLES;
  
  databaseserver mariadb > CREATE USER 'datacenter'@'10.20.0.11' IDENTIFIED BY 'Deltion123!';
  databaseserver mariadb > GRANT Insert ON datacenter.* TO 'datacenter'@'10.20.0.11';
  databaseserver mariadb > GRANT Update ON datacenter.* TO 'datacenter'@'10.20.0.11';
  databaseserver mariadb > GRANT Select ON datacenter.* TO 'datacenter'@'10.20.0.11';
  
  databaseserver mariadb > DESCRIBE mysql.user;
  databaseserver mariadb > SELECT User FROM mysql.user;
  databaseserver mariadb > SELECT User,Host FROM mysql.user WHERE User = 'datacenter';
  
  databaseserver mariadb > SHOW GRANTS FOR 'datacenter'@'10.20.0.11';
  
  databaseserver mariadb > ALTER USER 'datacenter'@'10.20.0.11' IDENTIFIED BY 'Deltion123!@';
  databaseserver mariadb > FLUSH PRIVILEGES;
  
  databaseserver mariadb > EXIT;

Controle

Controleer of je vanaf de webserver met het datacenter account kunt inloggen en gegevens kunt muteren in de datacenter-database.

  webserver $ mysql -h10.20.0.12 -udatacenter -p
  webserver mariadb> USE datacenter;
  webserver mariadb> SHOW TABLES;
  webserver mariadb> SELECT * FROM oses;
  webserver mariadb> SELECT * FROM servers;
  webserver mariadb> INSERT INTO servers (osnaam,osid) VALUES ("dummy",3);
  webserver mariadb> UPDATE servers SET osnaam="Dummie" WHERE osnaam="dummy";