Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.xreatlabs.space/llms.txt

Use this file to discover all available pages before exploring further.

Database Setup

NexAuth supports multiple database backends. Choose the one that best fits your server size and infrastructure.

Supported Database Types

DatabaseBest ForSetup ComplexityPerformance
SQLiteSmall servers, developmentEasyGood for small scale
MySQL/MariaDBMedium to large serversMediumExcellent performance
PostgreSQLLarge servers, enterprisesMediumExcellent performance
Perfect for small servers and development setups. No additional services required.

Configuration

database {
    type=nexauth-sqlite
    properties {
        sqlite {
            path="user-data.db"
        }
    }
}

Database Location

The database file will be created at:
  • Linux: /path/to/server/plugins/NexAuth/nexauth.db
  • Windows: \path\to\server\plugins\NexAuth\nexauth.db

Advantages

  • โœ… No setup required
  • โœ… No additional services
  • โœ… Easy to backup (just copy the .db file)
  • โœ… Good for small servers (< 100 players)

Disadvantages

  • โŒ Not recommended for large servers
  • โŒ Single file can become fragmented
  • โŒ No concurrent connection optimization
SQLite is perfect for development, testing, and small production servers with less than 100 concurrent players.

Database Migration

Migrating from SQLite to MySQL

  1. Stop your server
  2. Install MySQL and create database/user
  3. Modify your config to use MySQL
  4. Start server - NexAuth will automatically migrate data

Manual Migration (if needed)

-- Export from SQLite (using sqlite3 command line)
sqlite3 nexauth.db ".dump" > nexauth_dump.sql

-- Convert for MySQL (replace SQLite-specific syntax)
sed 's/TEXT/TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci/g' nexauth_dump.sql > nexauth_mysql.sql

-- Import to MySQL
mysql -u nexauth_user -p nexauth < nexauth_mysql.sql

Performance Optimization

MySQL/MariaDB Optimizations

-- Optimize for InnoDB
ALTER TABLE nexauth_users ENGINE = InnoDB;
ALTER TABLE nexauth_sessions ENGINE = InnoDB;
ALTER TABLE nexauth_totp ENGINE = InnoDB;

-- Add indexes for better performance
CREATE INDEX idx_username ON nexauth_users(username);
CREATE INDEX idx_uuid ON nexauth_users(uuid);
CREATE INDEX idx_session_token ON nexauth_sessions(token);

PostgreSQL Optimizations

-- Add indexes for better performance
CREATE INDEX idx_users_username ON nexauth_users(username);
CREATE INDEX idx_users_uuid ON nexauth_users(uuid);
CREATE INDEX idx_sessions_token ON nexauth_sessions(token);

-- Consider for very large tables
ALTER TABLE nexauth_users SET (autovacuum_vacuum_scale_factor = 0.1);

Backup Strategies

# Simple copy
cp plugins/NexAuth/nexauth.db /path/to/backup/

# Or use sqlite3
sqlite3 plugins/NexAuth/nexauth.db ".backup /path/to/backup/nexauth-$(date +%Y%m%d).db"

Troubleshooting Database Issues

Common Connection Problems

โ€Access Deniedโ€ Errors

-- Check MySQL user privileges
SHOW GRANTS FOR 'nexauth_user'@'localhost';

-- Or recreate user with proper permissions
DROP USER 'nexauth_user'@'localhost';
CREATE USER 'nexauth_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON nexauth.* TO 'nexauth_user'@'localhost';
FLUSH PRIVILEGES;

Database Connection Timeout

  • Check if database service is running
  • Verify connection details in config
  • Increase connect-timeout setting
  • Check firewall settings

Table Not Found

  • Database might not be created yet
  • Check user has CREATE permissions
  • Look for error logs during startup

Performance Issues

High CPU Usage

  • Increase connection pool size
  • Add more indexes
  • Check for slow queries
  • Consider SSD storage

Memory Issues

  • Adjust connection pool size
  • Monitor database server memory usage
  • Consider database server upgrades

Connection Security

MySQL Security Recommendations

-- Create user with limited privileges
CREATE USER 'nexauth_user'@'localhost' IDENTIFIED BY 'secure_password';
GRANT SELECT, INSERT, UPDATE, DELETE ON nexauth.* TO 'nexauth_user'@'localhost';
FLUSH PRIVILEGES;

-- Enable SSL for connections
-- In my.cnf:
[mysqld]
require_secure_transport=ON
ssl-ca=/path/to/ca.pem
ssl-cert=/path/to/server-cert.pem
ssl-key=/path/to/server-key.pem

PostgreSQL Security Recommendations

-- Create user with limited privileges
CREATE USER nexauth_user WITH PASSWORD 'secure_password';
GRANT CONNECT ON DATABASE nexauth TO nexauth_user;
GRANT USAGE ON SCHEMA public TO nexauth_user;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO nexauth_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO nexauth_user;

-- Enable SSL connections
# In postgresql.conf:
ssl = on
ssl_cert_file = 'server.crt'
ssl_key_file = 'server.key'

Monitoring Database Health

MySQL/MariaDB Monitoring

# Check database status
mysqladmin -u nexauth_user -p status

# Monitor connections
SHOW PROCESSLIST;
SHOW STATUS LIKE 'Threads_connected';

# Check table sizes
SELECT table_name, ROUND(data_length/1024/1024, 2) AS size_mb
FROM information_schema.tables
WHERE table_schema = 'nexauth';

PostgreSQL Monitoring

-- Check active connections
SELECT count(*) FROM pg_stat_activity;

-- Check database size
SELECT pg_size_pretty(pg_database_size('nexauth'));

-- Check table sizes
SELECT table_name, pg_size_pretty(pg_total_relation_size('tablename'))
FROM pg_tables
WHERE schemaname = 'public';

Next Steps

After setting up your database:
  • ๐Ÿ“– First Run Configuration for initial plugin setup
  • ๐Ÿ“– Installation Guides for deployment options
  • ๐Ÿ“– Performance optimization for your specific use case
  • ๐Ÿ“– Advanced database configurations (coming soon)