Nethence Newdoc Olddoc Lab Your IP BBDock  

MariaDB notes

Create db with UTF-8 charset & collate

Access the instance as sql root,

app=mariadbprod
    docker exec -ti $app mysql -uroot -p
    show databases;

Create a database with UTF-8,

    create database dbname
        DEFAULT CHARACTER SET utf8
        DEFAULT COLLATE utf8_general_ci;
    grant all privileges on dbname.* to dbnameuser identified by 'USERPASS_HERE';
    flush privileges;

and check,

docker exec -ti $app mysql -udbnameuser -pUSERPASS_HERE dbname
show tables;

See Database Character Set and Collation on how to check that the charset is right. That’s a MySQL 5 doc but should also work with MariaDB. On a db,

USE db_name;
SELECT @@character_set_database, @@collation_database;

or alternatively without being on that db,

SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME
FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'db_name';

The defaults are not right (latin1 instead of utf8),

    SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';

Injecting SQL

Inject whatever SQL code you want in it,

app=mariadbprod
    docker exec -ti $app mysql -udbnameuser -pUSERPASS_HERE dbname < schema.sql

and check,

docker exec -ti $app mysql -udbnameuser -pUSERPASS_HERE dbname
show tables;
...

Home | GitHub | Donate