<@U04UQ68083H> can i change database backend(postg...
# ory-copilot
f
@chilly-king-10285 can i change database backend(postgresql to mariadb) effortless?
c
A message from kapa.ai
No, you cannot change the database backend from PostgreSQL to MariaDB effortlessly. Ory currently supports relational databases such as PostgreSQL, MySQL, SQLite, and CockroachDB. Support for other databases, including MariaDB, is not planned at the moment. Ory no longer supports custom database adapters due to the complexity involved. Writing your own database adapter is strongly discouraged as it can lead to serious security issues. However, Ory does allow for swapping out local services with third-party services without any changes to the app’s code. For example, a local MySQL database can be swapped with one managed by a third party (such as Amazon RDS) without any changes to the app’s code. In such cases, only the resource handle in the config needs to change. Sources: - [Support QA](https://www.ory.sh/docs/ecosystem/software-architecture-philosophy#external-services-postgresql-mysql--are-attached-resources) - [Architecture principles](https://www.ory.sh/docs/ecosystem/software-architecture-philosophy#external-services-postgresql-mysql--are-attached-resources)
f
@chilly-king-10285 then, can i change database backend(postgresql to mysql) effortless?
c
A message from kapa.ai
Yes, you can change the database backend from PostgreSQL to MySQL without making changes to the application's code. Ory treats both local and third-party services as attached resources, accessed via a URL or other locator/credentials stored in the config. To switch from PostgreSQL to MySQL, you would need to change the
dsn
(Data Source Name) configuration key. If the
dsn
is prefixed with
mysql://
, then MySQL will be used as the storage backend. An example configuration would look like this:
DSN=<mysql://user:password@tcp(host:123)/database?parseTime=true>
. Please note that you also need to adjust the DSN parameters according to your MySQL setup. These parameters include
max_conns
,
max_idle_conns
,
max_conn_lifetime
,
max_conn_idle_time
, and others. Sources: - [MySQL Configuration](https://www.ory.sh/docs/self-hosted/deployment#mysql) - [Architecture principles](https://www.ory.sh/docs/ecosystem/software-architecture-philosophy#external-services-postgresql-mysql--are-attached-resources)
f
@chilly-king-10285 Then how can move user data?
c
A message from kapa.ai
To migrate user data from one database to another, you would typically export the data from the source database and then import it into the target database. However, the specific steps can vary depending on the databases involved and the specific data structures used. For Ory, if you're migrating from Auth0 to Ory, there's a specific process outlined in the documentation. This involves creating a bulk user export from Auth0, then running a script to import this data into Ory. The script requires certain tools to be installed, such as
jq
and
Gzip
. Here are the steps to create a bulk user export from Auth0: 1. Go to your Auth0 dashboard and navigate to Applications → APIs. 2. Select Auth0 Management API and go to the API Explorer tab. Copy the displayed token. 3. Go to Authentication and navigate to Database. 4. Click the connection for which you want to export user data and copy its ID. Then, to run the script: 1. Export the required environment variables:
Copy code
bash export AUTH0_DOMAIN="$<http://your_auth0_domain.auth0.com|your_auth0_domain.auth0.com>"   export AUTH0_CONNECTION_ID="$your_auth0_connection_id"   export AUTH0_TOKEN="$your_auth0_management_api_token"
2. Run the script:
Copy code
bash bash <(curl <https://raw.githubusercontent.com/ory/docs/master/code-examples/migrate-to-ory/0-get-auth0-user-data.sh>)
Please note that this process is specific to migrating from Auth0 to Ory. If you're migrating from a different system or to a different system, the process could be different. Sources: - [Migrate from Auth0](https://www.ory.sh/docs/migrate-to-ory/migrate-from-auth0) - [Create a bulk user export](https://www.ory.sh/docs/migrate-to-ory/migrate-from-auth0#create-a-bulk-user-export)
f
@chilly-king-10285 No, i want move user data from kratos(postgres) to kratos(mysql)
c
A message from kapa.ai
Migrating user data from one database to another in Ory Kratos (from PostgreSQL to MySQL in this case) is not directly documented in the provided knowledge sources. However, typically such a migration would involve exporting the data from the PostgreSQL database and then importing it into the MySQL database. Here are general steps you might follow: 1. Export your data from the PostgreSQL database. This could be done using a tool like
pg_dump
. 2. Convert the exported data into a format that can be imported into MySQL. This might require a tool or script, depending on the format of the exported data. 3. Import the converted data into the MySQL database using a tool like
mysqlimport
. Please note that these are general steps and might not work out of the box for your specific situation. You should adjust them based on your environment and requirements. Also, it's important to back up your data before starting the migration process to prevent data loss. And you should thoroughly test the process and verify the data in the new database before switching over to it in production. Since this process can be complex and error-prone, you might want to consider getting help from someone with experience in database migrations. Unfortunately, I don't have a specific guide or documentation for this process in the context of Ory Kratos in the provided knowledge sources. For more detailed instructions, you might want to refer to the PostgreSQL and MySQL documentation, or other resources specific to these databases.