-
Accessing your database
Accessing your MariaDB instance
MariaDB in Pukki is still in beta
This means that it hasn't been tested as extensively as PostgreSQL, and there might still be large changes to how Pukki manages MariaDB database instances.
Graphical user interface
You can find a non-comprehensive list of different graphical interfaces for using MariaDB on MariaDB's homepage.
MariaDB Connectors
MariaDB Connectors are used for creating database connections from applications, and are available for many popular programming languages. You can find more information regarding their usage and configuration in MariaDB's documentation:
Please pay special attention to SSL configuration - as Pukki only allows SSL connections to its MariaDB instances, you will have to set up configuration options related to that.
Command-line client mariadb and mysql
MariaDB's documentation on the command-line client
The recommended CLI client to use is mariadb. The mysql client does still work, but is
usually a symbolic link to mariadb.
Example commands for accessing your database:
or
--sslmeans the MariaDB client connects using SSL. This is necessary as Pukki database instances enforce encrypted connections.--passwordmeans the client prompts for a password. You can specify one on the command line (like--password=password), but that is considered insecure.--hostspecifies the host address to connect to. In Pukki this is almost always your database instance's public IP address.--userspecifies which user to connect to the database as.${DATABASE_NAME}specifies which database on the server to connect to.
Using command line with .my.cnf
If you are frequently connecting to the same database, it might be worthwhile to set up a
.my.cnf configuration file in your home directory to store the necessary flags and options.
- Create an empty
.my.cnffile in your home directory, and restrict its access permissions:
- Edit the configuration file with your favorite editor and add the following options:
As storing the password in a plaintext file isn't recommended, you can leave it empty to always prompt for the password when connecting:
Export Your Current MariaDB Database
To migrate your database, you must first create a backup (or "dump") of your existing MariaDB instance. MariaDB provides the mariadb-dump utility, which exports a database to a plain SQL file. This format is commonly used for backups, migrations, and data archiving.
Database dumps can be used to migrate data away from Pukki or to keep an independent backup outside CSC services. This could be a useful tool that will help you to achieve your backup strategy.
Run the mariadb-dump command to create a SQL dump of your database:
mariadb-dump -h ${PUBLIC_IP} -u ${USERNAME} -p${PASSWORD} --ssl --ssl-verify-server-cert=OFF ${DATABASE_NAME} > database_backup.sql
-p${PASSWORD}: Password with no space after-p. If you use-palone,mariadb-dumpprompts for the password interactively.--ssl: Enables an encrypted connection. Required for all Pukki MariaDB connections.--ssl-verify-server-cert=OFF: This flag keeps the connection encrypted while skipping certificate validation. Themariadb-dumpis stricter and requires this flag explicitly.database_backup.sql: The name of the output file.
To dump all databases at once:
mariadb-dump -h ${PUBLIC_IP} -u ${USERNAME} -p${PASSWORD} --ssl --ssl-verify-server-cert=OFF --all-databases > all_databases_backup.sql
--all-databases: Exports all databases the user has access to.
Common issues with CLI connections
If a password prompt appears, but the client is afterwards stuck connecting for a long time, you should
double-check that the host argument is correct, and that the firewall allows connections from your client's
address.
ERROR 3159 (08004): Connections using insecure transport are prohibited while --require_secure_transport=ON.
You tried to connect to the database without --ssl.
Either your password or your username is wrong.
Either the database specified does not exist, or the username specified has no access to it.
The --ssl flag alone isn't enough, you need to supply the client --ssl-verify-server-cert=OFF to skip certificate verification.
Accessing your Pukki MariaDB database from Puhti
- Ensure your database instance allows network traffic from Puhti.
sshonto Puhti and load themariadbmodule- Now you can connect to the database with the mariadb-client
Some useful SQL commands
List databases
List tables
Show table descriptions
Change database
Example query
Show all database settings
or if you want to show a subset you can use LIKE
% here indicates a wildcard - this lists all variables that begin with innodb.
Import database dump