Time for action - creating the database

For simplicity, let's assume that you're going to host the database on the same server as Cacti:

  1. Execute the following command to log on to the MySQL/MariaDB CLI:
mysql -u root mysql 
  1. The default MySQL root account does not have a password set, so you can do it now:
SET PASSWORD FOR root@localhost = PASSWORD('MyN3wpassw0rd'); 
  1. You can remove the example database, as it is not needed:
DROP DATABASE test; 
  1. Together with the example database, some example users may have been created. You can remove these with the following command:
DELETE FROM user WHERE NOT (host = "localhost" AND user = "root"); 
  1. On a CentOS distribution you can use the following command to guide you through the preceding steps:
/usr/bin/mysql_secure_installation   
  1. Now that MySQL is secured, let's create the Cacti database. Enter the following command. This will ask for the MySQL root password which you provided in setup step 1 or step 5. When finished, you'll have an empty database called cacti:
mysqladmin -u root -p create cacti 
  1. As the database is still empty, you need to create the tables and fill them with the initial data that comes with Cacti. The following command will do just that. Once the command finishes you'll have a working cacti database:
mysql -u root -p cacti < /var/www/html/cacti/cacti.sql 
  1. Unfortunately, Cacti is still unable to access it, therefore you're now going to create a database user for Cacti. Enter the following command:
mysql -u root -p mysql 
  1. You'll see the following on the screen:
  1. Type the next few lines in the MySQL prompt to create the Cacti user and allow him to use the time_zone_name table of MySQL. Make sure to choose a strong password:
GRANT SELECT ON mysql.time_zone_name TO cactiuser@localhost IDENTIFIED BY 'MyV3ryStr0ngPassword'; 
GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'MyV3ryStr0ngPassword'; 
flush privileges; 
exit