Skip to content

Commit adb145b

Browse files
committed
docs(database): describe moving Poweradmin tables to their own database
1 parent 1abb1ba commit adb145b

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

docs/configuration/database.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,57 @@ return [
3434
];
3535
```
3636

37+
## Moving Poweradmin Tables to Their Own Database
38+
39+
Many older installations keep the Poweradmin tables in the PowerDNS database.
40+
On MySQL/MariaDB you can split them without re-importing anything, because
41+
`RENAME TABLE` moves a table between databases on the same server atomically
42+
and keeps its data.
43+
44+
1. Bring the schema up to date first. Run any missing update scripts against the
45+
shared database (see [Which update scripts have already run?](../upgrading/index.md#which-update-scripts-have-already-run)).
46+
2. Take a dump of the shared database.
47+
3. Create the new database and grant the Poweradmin user access to it:
48+
49+
```sql
50+
CREATE DATABASE poweradmin CHARACTER SET utf8mb4;
51+
GRANT ALL ON poweradmin.* TO 'poweradmin'@'%';
52+
```
53+
54+
4. Generate the rename statements. Everything in the shared database that is not
55+
one of PowerDNS's own tables belongs to Poweradmin:
56+
57+
```sql
58+
SELECT CONCAT('RENAME TABLE `powerdns`.`', table_name, '` TO `poweradmin`.`', table_name, '`;')
59+
FROM information_schema.tables
60+
WHERE table_schema = 'powerdns'
61+
AND table_name NOT IN ('domains', 'records', 'supermasters', 'comments',
62+
'domainmetadata', 'cryptokeys', 'tsigkeys');
63+
```
64+
65+
Review the output, then run it.
66+
67+
5. Point Poweradmin at the new layout in `config/settings.php`:
68+
69+
```php
70+
'database' => [
71+
'name' => 'poweradmin',
72+
'pdns_db_name' => 'powerdns',
73+
// ...
74+
],
75+
```
76+
77+
6. Log in and open the zone list, users, and zone templates pages.
78+
79+
A name server that replicates the database can now replicate only `powerdns`.
80+
Future update scripts run against the `poweradmin` database. The 4.3.0 script
81+
reads the PowerDNS `domains` table; its header explains how to qualify that
82+
name when `pdns_db_name` is set.
83+
84+
PostgreSQL and SQLite do not support `pdns_db_name`. To separate the databases
85+
there, switch to [API backend mode](powerdns-api.md#migrating-from-sql-to-api-backend),
86+
which needs only the Poweradmin tables.
87+
3788
## Database Types
3889
3990
Poweradmin supports multiple database backends:

0 commit comments

Comments
 (0)