diff --git a/PostgreSQL-Storage.md b/PostgreSQL-Storage.md new file mode 100644 index 0000000..56580c2 --- /dev/null +++ b/PostgreSQL-Storage.md @@ -0,0 +1,130 @@ +This option one of the 4 storage options of Dynmap. It is an advanced storage layout, for example a separate service that hosts the database needs to be set-up, which will be explained in this guide. + +### Installation +Apologies, I would need to go over installation of the database again myself. Documentation can be found at https://www.postgresql.org/ + +### Configuring Postgres Database + +Using a terminal or command line on the server that is hosting the minecraft server, we will create a new database and add some database users. + +### Creating a new database in Postgres + +You will notice statements like "CREATE DATABASE" after entering a command. This is normal. + + C:\Program Files\PostgreSQL\15\bin>psql -U postgres + Password for user postgres: + postgres=# CREATE DATABASE ; + CREATE DATABASE + +### Add new users + +**note:** +If the Postgres server is on the same server as the minecraft server. should just be localhost +
postgres=# CREATE USER  WITH PASSWORD '';
+CREATE ROLE
+postgres=# ALTER DATABASE dynmap OWNER TO dynmap;
+ALTER DATABASE
+ +If you made a mistake and need to delete the user, this is how. + +
postgres=# DROP USER ;
+ +After you create a new user, try logging into the user. (after you logout from the postgres user via "exit") + +
postgres -u 
+psql (15.3)
+WARNING: Console code page (437) differs from Windows code page (1252)
+         8-bit characters might not work correctly. See psql reference
+         page "Notes for Windows users" for details.
+Type "help" for help.
+
+postgres=#
+ +### Postgres Privileges/Permissions + +Postgres has these permissions available to set to MySQL users. + +* ALL PRIVILEGES - Grant all privileges to the user +* CREATE - Allows user to create databases/tables +* DELETE - Allows user to delete rows(data) from a table +* DROP - Allows user to drop databases and tables +* INSERT - Allows user to insert rows(data) to a table +* SELECT - Allows user to read from a database +* UPDATE - Allows user to update data in a table + +### Editing dynmap/configuration.txt + +The database driver for Postgres should be installed already (JDBC I believe, verify this). + +The last step is to configure the dynmap configuration.txt so it connects to the database and uses it for storage. +change the following part of the configuration.txt: + +```yaml +storage: + # Filetree storage (standard tree of image files for maps) + type: filetree + # SQLite db for map storage (uses dbfile as storage location) + #type: sqlite + #dbfile: dynmap.db + # MySQL DB for map storage (at 'hostname':'port' with flags "flags" in database 'database' using user 'userid' password 'password' and table prefix 'prefix') + #type: mysql + #hostname: localhost + #port: 3306 + #database: dynmap + #userid: dynmap + #password: dynmap + #prefix: "" + #flags: "?allowReconnect=true&autoReconnect=true" +``` + +to: + +
+Postgres enabled (Click to expand) + +```yaml +storage: + # Filetree storage (standard tree of image files for maps) + #type: filetree <- DONT FORGET TO COMMENT THIS OUT + # SQLite db for map storage (uses dbfile as storage location) + #type: sqlite + #dbfile: dynmap.db + # MySQL DB for map storage (at 'hostname':'port' with flags "flags" in database 'database' using user 'userid' password 'password' and table prefix 'prefix') + type: postgres + hostname: + port: 5432 + database: + userid: + password: + prefix: "" # Can add prefix for tables if you want + flags: "?allowReconnect=true&autoReconnect=true" +``` +
+ +example: + +
+MySQL example (Click to expand) + +```yaml +storage: + # Filetree storage (standard tree of image files for maps) + #type: filetree <- DONT FORGET TO COMMENT THIS OUT + # SQLite db for map storage (uses dbfile as storage location) + #type: sqlite + #dbfile: dynmap.db + # MySQL DB for map storage (at 'hostname':'port' with flags "flags" in database 'database' using user 'userid' password 'password' and table prefix 'prefix') + type: postgres + hostname: localhost + port: 5432 + database: dynmap + userid: dynmap + password: CHANGE_ME_QUICK! + prefix: "" # Can add prefix for tables if you want + flags: "?allowReconnect=true&autoReconnect=true" +``` +
+Now save the file and start the minecraft server, check if dynmap succesfully created and connected to the Postgres database. + +## Post setup +All that was needed for me to get this working was to create the database. I think I had some issues with my user's privileges so those may need to be adjusted. \ No newline at end of file