Skip to content

Using 256 or 4096 databases

Ron Rennick edited this page Jul 24, 2019 · 1 revision

256 databases

In your db-settings.php, set $shardb_hash_length=2;. The database names will be your_prefix_00 through your_prefix_ff.

If you have SSH access, you can create db-create.sql via the terminal by using the following command:

$ for D in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do \
for E in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do \
echo CREATE DATABASE your_prefix_$D$E';' >> db-create.sql; \
echo GRANT ALL ON your_prefix_$D$E.* TO your_user';' >> db-create.sql; \
done ; \
done ;

4096 databases

In your db-settings.php, set $shardb_hash_length=3;. The database names will be your_prefix_000 through your_prefix_fff.

If you have SSH access, you can create db-create.sql via the terminal by using the following command:

$ for D in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do \
for E in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do \
for F in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do \
echo CREATE DATABASE your_prefix_$D$E$F';' >> db-create.sql; \
echo GRANT ALL ON your_prefix_$D$E$F.* TO your_user';' >> db-create.sql; \
done ; \
done ; \
done ;

Note: Neither of the above scripts includes the global or home database.

Clone this wiki locally