Connecting with the mysql and mariadb command-line clients
The commands that connect the stock mysql and mariadb clients to raftdb-mysql, how TLS and authentication plugins behave, and the first statements to try.
raftdb-mysql speaks the MySQL wire protocol, so the stock clients connect without change.
The MySQL client#
mysql -h 127.0.0.1 -P 3307 -u app -pEnter the password of the user = app:... line of mysql.conf (or of an account made with CREATE USER). Use 127.0.0.1, not localhost: on Unix, localhost makes the client look for a socket file, and raftdb-mysql listens on TCP only. The real mysql 9.7 client works with exactly -h 127.0.0.1 -P PORT -u USER -pPASSWORD.
mysql> SELECT VERSION();The answer is 8.0.36-Raft DB for the MySQL dialect. @@version_comment is Raft DB (setting identity, see "Settings of raftdb-mysql").
The SQL Server and PostgreSQL clients#
The other front-ends have their own programs and ports. Each keeps its usual default (the installer takes the next free port when one is taken and prints it):
sqlcmd -S 127.0.0.1,1433 -U admin -C
psql "host=127.0.0.1 port=5432 user=admin dbname=postgres"raftdb-mssql answers SQL Server clients over TDS and raftdb-pg answers PostgreSQL clients; what each one supports is in the SQL Server and PostgreSQL chapters.
The MariaDB client#
Start the front-end with dialect = mariadb and connect with mariadb:
mariadb --skip-ssl -h 127.0.0.1 -P 3308 -u app -p--skip-ssl is needed with the MariaDB 11.4 client when the front-end has no TLS configured: MariaDB servers of 11.4 and later ask a client for TLS when they can, and the MariaDB command-line client wants the option against a server without TLS. With ssl_cert and ssl_key set the client connects with no option. VERSION() answers 11.4.13-MariaDB-Raft DB.
TLS#
raftdb-mysql offers TLS when ssl_cert and ssl_key are configured (or ssl = auto): mysql --ssl-mode=REQUIRED and the mariadb client then connect encrypted, and --ssl-mode=VERIFY_CA --ssl-ca=server.pem verifies the server. Without those settings the handshake does not set the SSL capability, a client in its default "preferred" mode connects in clear, and a client that requires TLS cannot connect. See TLS and encryption.
Authentication plugins#
| Dialect | Offered first | Also works |
|---|---|---|
mysql | caching_sha2_password | mysql_native_password (a client that offers another plugin is asked to switch) |
mariadb | mysql_native_password | caching_sha2_password |
caching_sha2_password succeeds on the fast path because the front-end holds the verifier of the password; there is no RSA key exchange. MariaDB's ed25519, parsec and gssapi are not offered.
First statements#
SHOW DATABASES;
CREATE DATABASE shop;
USE shop;
CREATE TABLE item (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(30) NOT NULL, price DECIMAL(8,2));
INSERT INTO item (name, price) VALUES ('pen', 1.50), ('book', 12.00);
SELECT * FROM item;The tutorial goes on from here, using only statements that were checked against MySQL and MariaDB.
What a database name is#
SHOW DATABASES lists the databases created through this front-end (and only those), plus information_schema. A Raft DB database that the native API created is not listed by a front-end that did not create it.
If it does not connect#
| Symptom | Likely cause |
|---|---|
Can't connect to MySQL server on '127.0.0.1:3307' | raftdb-mysql is not running, or listens on another port (listen). |
ERROR 1045 (28000): Login refused for user 'app'@'localhost' (password supplied: YES) | Wrong user or password. Loopback clients are shown as localhost. |
ERROR 1040 (08004): Too many connections | max_connections reached. |
MariaDB client: TLS/SSL error | Configure TLS on the front-end, or add --skip-ssl. |
ERROR 2013 (HY000): Lost connection ... | The login took longer than 10 seconds, or the server stopped. |
More in Connection problems.