Run this whole guide as root
or using sudo
Install MariaDB
apt install -y mariadb-server
Run the secure installation
mysql_secure_installation
Login to the database as root
mysql
Create a new database
CREATE DATABASE pdns;
Create a new DB user
CREATE USER 'pdns'@'localhost' IDENTIFIED BY '***********************';
Grant all privileges on the new database for the new user
GRANT ALL ON pdns.* TO 'pdns'@'localhost';
Flush privileges and exit
FLUSH PRIVILEGES;
exit
Add the PowerDNS repo
Install PDNS Authoritative server and the MySQL Backend
apt install pdns-server pdns-backend-mysql
Import the provided schema.mysql.sql
schema in to the pdns
database
mysql -u pdns -p -D pdns < /usr/share/pdns-backend-mysql/schema/schema.mysql.sql
Check list of tables on the pdns
database
mysqlshow pdns
Should return: (This is what the latter schema import built)
Database: pdns
+----------------+
| Tables |
+----------------+
| comments |
| cryptokeys |
| domainmetadata |
| domains |
| records |
| supermasters |
| tsigkeys |
+----------------+
Stop PowerDNS
systemctl stop pdns.service
Remove the BIND config. Cause eff BIND.
rm /etc/powerdns/pdns.d/bind.conf
Create a new config file for the MySQL backend
bash -c "cat > /etc/powerdns/pdns.d/mysql.conf" <<'EOF'
# Define the gmysql backend
launch+=gmysql
# Details MariaDB database for PowerDNS
gmysql-host=127.0.0.1
gmysql-port=3306
gmysql-dbname=pdns
gmysql-user=pdns
gmysql-password=***********
gmysql-dnssec=yes
# gmysql-socket=
EOF
Modify the permissions of the new config file
chown pdns:pdns /etc/powerdns/pdns.d/mysql.conf && \
chmod 640 /etc/powerdns/pdns.d/mysql.conf
Start and check the status of PowerDNS
systemctl start pdns.service && \
systemctl status pdns.service