Connecting to a server configured for catalogs
When connecting to the MariaDB server configured for catalogs, one has to provide the catalog to connect to. There are several ways to do this:
All new native MariaDB clients will support the --catalog
option:
mariadb --catalog=mine test
New and old clients can use the 'catalog_name.database_name' syntax to connect:
mariadb mine.test
This will connect the user to the 'mine' catalog and the database 'test'.
Note that one consequence of this is that one should not have a database that contains '.' in
the name. If one would have this, one can still connect to it by using the --catalog=
option or prefixing the database with the catalog, like in def.data.base.name
.
One will also be able to configure the MariaDB server to automatically choose catalog depending on the port or IP they are using to connect to the server. This is done by adding to the catalog specific my.cnf file, residing in the catalog directory:
[[mariadbd]] --port=# --connect-ip=
If catalogs is not specified either directly (---catalog=#) or indirectly (with port or ip) the catalog def
will be used.
When one is connecting to a server not configured for catalogs one can still use mariadb --catalog=def
or mariadb def.datbase_name
.
One can check if a server is supporting catalogs with:
MariaDB [test]> select @@catalogs; +------------+ | @@catalogs | +------------+ | 0 | +------------+ MariaDB [test]> use catalog foo; ERROR 4193 (HY000): MariaDB is not configured to support catalogs
0 means that he server is not configured for catalogs.