Importing data into MySQL / MariaDB database from SQL dump file:
- Ensure database exists:
create DATABASE IF NOT EXISTS <db name>;
- Import data:
mysql <db name> < ./path/to/db.sql
See also: [[memos/AAXMo7MCQfyrDTJXnTsyr5]]
MariaDB specifically has a huge pitfall, the mariadb-import
command: https://mariadb.com/kb/en/mariadb-import/ ...it seems to always give a strange error, mariadb-import: Error: 1146, Table '<db name>.Db' doesn't exist, when using table: Db
, like it wants to append something to the db name. It's best to not use it, and use instead the above.