1 | | ==== MySQL ==== |
| 1 | ==== MySQL (MariaDB) ==== |
| 2 | |
| 3 | The 825gen2 includes MariaDB, but service is not enabled to start automatically |
| 4 | |
| 5 | {{{ |
| 6 | root@imx8mq-var-dart:~# mysql |
| 7 | ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) |
| 8 | }}} |
| 9 | |
| 10 | Type: |
| 11 | {{{ |
| 12 | systemctl enable mysqld.service |
| 13 | }}} |
| 14 | Now mysqld starts up upon boot |
| 15 | |
| 16 | {{{ |
| 17 | root@imx8mq-var-dart:~# mysql |
| 18 | Welcome to the MariaDB monitor. Commands end with ; or \g. |
| 19 | Your MariaDB connection id is 4 |
| 20 | Server version: 10.7.4-MariaDB Source distribution |
| 21 | |
| 22 | Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. |
| 23 | |
| 24 | Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. |
| 25 | |
| 26 | MariaDB [(none)]> |
| 27 | |
| 28 | |
| 29 | MariaDB [(none)]> show databases; |
| 30 | +--------------------+ |
| 31 | | Database | |
| 32 | +--------------------+ |
| 33 | | information_schema | |
| 34 | | mysql | |
| 35 | | performance_schema | |
| 36 | | test | |
| 37 | +--------------------+ |
| 38 | 4 rows in set (0.002 sec) |
| 39 | |
| 40 | MariaDB [(none)]> use information_schema; |
| 41 | Reading table information for completion of table and column names |
| 42 | You can turn off this feature to get a quicker startup with -A |
| 43 | |
| 44 | Database changed |
| 45 | MariaDB [information_schema]> show tables; |
| 46 | +---------------------------------------+ |
| 47 | | Tables_in_information_schema | |
| 48 | +---------------------------------------+ |
| 49 | | ALL_PLUGINS | |
| 50 | | APPLICABLE_ROLES | |
| 51 | | CHARACTER_SETS | |
| 52 | | CHECK_CONSTRAINTS | |
| 53 | | COLLATIONS | |
| 54 | | COLLATION_CHARACTER_SET_APPLICABILITY | |
| 55 | | COLUMNS | |
| 56 | | COLUMN_PRIVILEGES | |
| 57 | | ENABLED_ROLES | |
| 58 | | ENGINES | |
| 59 | | EVENTS | |
| 60 | | FILES | |
| 61 | | GLOBAL_STATUS | |
| 62 | | GLOBAL_VARIABLES | |
| 63 | | KEY_CACHES | |
| 64 | | KEY_COLUMN_USAGE | |
| 65 | | OPTIMIZER_TRACE | |
| 66 | | PARAMETERS | |
| 67 | | PARTITIONS | |
| 68 | | PLUGINS | |
| 69 | | PROCESSLIST | |
| 70 | | PROFILING | |
| 71 | | REFERENTIAL_CONSTRAINTS | |
| 72 | | ROUTINES | |
| 73 | | SCHEMATA | |
| 74 | | SCHEMA_PRIVILEGES | |
| 75 | | SESSION_STATUS | |
| 76 | | SESSION_VARIABLES | |
| 77 | | STATISTICS | |
| 78 | | SYSTEM_VARIABLES | |
| 79 | | TABLES | |
| 80 | | TABLESPACES | |
| 81 | | TABLE_CONSTRAINTS | |
| 82 | | TABLE_PRIVILEGES | |
| 83 | | TRIGGERS | |
| 84 | | USER_PRIVILEGES | |
| 85 | | VIEWS | |
| 86 | | GEOMETRY_COLUMNS | |
| 87 | | SPATIAL_REF_SYS | |
| 88 | | CLIENT_STATISTICS | |
| 89 | | INDEX_STATISTICS | |
| 90 | | user_variables | |
| 91 | | TABLE_STATISTICS | |
| 92 | | USER_STATISTICS | |
| 93 | +---------------------------------------+ |
| 94 | 44 rows in set (0.002 sec) |
| 95 | |
| 96 | MariaDB [information_schema]> |
| 97 | |
| 98 | |
| 99 | MariaDB [information_schema]> use test; |
| 100 | Database changed |
| 101 | MariaDB [test]> show tables; |
| 102 | Empty set (0.001 sec) |
| 103 | |
| 104 | |
| 105 | MariaDB [test]> create table test_tbl( |
| 106 | -> tbl_id INT NOT NULL AUTO_INCREMENT, |
| 107 | -> title VARCHAR(100) NOT NULL, |
| 108 | -> description VARCHAR(200) NOT NULL, |
| 109 | -> PRIMARY KEY(tbl_id) |
| 110 | -> ); |
| 111 | Query OK, 0 rows affected (0.011 sec) |
| 112 | |
| 113 | |
| 114 | MariaDB [test]> show tables; |
| 115 | +----------------+ |
| 116 | | Tables_in_test | |
| 117 | +----------------+ |
| 118 | | test_tbl | |
| 119 | +----------------+ |
| 120 | 1 row in set (0.002 sec) |
| 121 | |
| 122 | |
| 123 | MariaDB [test]> select * from test_tbl; |
| 124 | Empty set (0.007 sec) |
| 125 | |
| 126 | MariaDB [test]> insert into test_tbl (title,description) values ('title1', 'desc1'); |
| 127 | Query OK, 1 row affected (0.002 sec) |
| 128 | |
| 129 | MariaDB [test]> insert into test_tbl (title,description) values ('Moby Dick', 'A whale of a story'); |
| 130 | Query OK, 1 row affected (0.002 sec) |
| 131 | |
| 132 | MariaDB [test]> select * from test_tbl; |
| 133 | +--------+-----------+--------------------+ |
| 134 | | tbl_id | title | description | |
| 135 | +--------+-----------+--------------------+ |
| 136 | | 1 | title1 | desc1 | |
| 137 | | 2 | Moby Dick | A whale of a story | |
| 138 | +--------+-----------+--------------------+ |
| 139 | 2 rows in set (0.002 sec) |
| 140 | }}} |
| 141 | |
| 142 | Create MySQL user to access database |
| 143 | {{{ |
| 144 | CREATE USER 'dbuser'@'localhost' IDENTIFIED BY '81440'; |
| 145 | flush privileges; |
| 146 | }}} |
| 147 | Allow user to access database 'test' from any IP address. |
| 148 | {{{ |
| 149 | GRANT ALL PRIVILEGES ON test.* TO 'dbuser'@'%' IDENTIFIED BY '81440'; |
| 150 | flush privileges; |
| 151 | }}} |
| 152 | |
| 153 | |
| 154 | Allow remote connection |
| 155 | {{{ |
| 156 | nano /etc/my.cnf |
| 157 | }}} |