-
Notifications
You must be signed in to change notification settings - Fork 1
MariaDB Cheat Sheet for Vtiger
Σύμφωνα με τις προαπαιτήσεις του Vtiger:
- storage_engine = InnoDB
- local_infile = ON (under [mysqld] section)
- sql_mode = empty (or NO_ENGINE_SUBSTITUTION) for MySQL 5.6+
- collation = utf8
Για επιβεβαιώσουμε οτι το mariaDB τα έχει ενεργά, ελέγχουμε με τις παρακάτω εντολές:
Storage Engine:
show global variables like 'default_storage_engine';
+------------------------+--------+
| Variable_name | Value |
+------------------------+--------+
| default_storage_engine | InnoDB |
+------------------------+--------+
Local infile:
show global variables like 'local_infile';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile | ON |
+---------------+-------+
Sql Mode:
show global variables like 'sql_mode';
+---------------+--------------------------------------------+
| Variable_name | Value |
+---------------+--------------------------------------------+
| sql_mode | NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+--------------------------------------------+
Collation:
select * from information_schema.schemata;
+--------------+--------------------+----------------------------+------------------------+----------+
| CATALOG_NAME | SCHEMA_NAME | DEFAULT_CHARACTER_SET_NAME | DEFAULT_COLLATION_NAME | SQL_PATH |
+--------------+--------------------+----------------------------+------------------------+----------+
| def | information_schema | utf8 | utf8_general_ci | NULL |
| def | mysql | utf8mb4 | utf8mb4_general_ci | NULL |
| def | phpmyadmin | utf8mb4 | utf8mb4_general_ci | NULL |
+--------------+--------------------+----------------------------+------------------------+----------+
Σημείωση: Change the character set and collation properties of the databases, tables, and columns to use utf8mb4 instead of utf8.:
# For each database:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
# For each table:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# For each column:
ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# (Don’t blindly copy-paste this! The exact statement depends on the column type, maximum length, and other properties. The above line is just an example for a `VARCHAR` column.)
Configure my.cnf
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
You can easily confirm these settings work correctly:
mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';
+--------------------------+--------------------+
| Variable_name | Value |
+--------------------------+--------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+--------------------------+--------------------+
10 rows in set (0.00 sec)
As you can see, all the relevant options are set to utf8mb4, except for character_set_filesystem which should be binary unless you’re on a file system that supports multi-byte UTF-8-encoded characters in file names, and character_set_system which is always utf8 and can’t be overridden.
Repair and optimize all tables
After upgrading the MySQL server and making the necessary changes explained above, make sure to repair and optimize all databases and tables. I didn’t do this right away after upgrading (I didn’t think it was necessary, as everything seemed to work fine at first glance), and ran into some weird bugs where UPDATE statements didn’t have any effect, even though no errors were thrown.
You could run the following MySQL queries for each table you want to repair and optimize:
# For each table
REPAIR TABLE table_name;
OPTIMIZE TABLE table_name;
Luckily, this can easily be done in one go using the command-line mysqlcheck utility:
$ mysqlcheck -u root -p --auto-repair --optimize --all-databases
This will prompt for the root user’s password, after which all tables in all databases will be repaired and optimized.
To view users and allowed connections:
SELECT User, Host FROM mysql.user;
To enable remote connection to mariadb:
sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf
change bind-address
to #bind-address
and save, exit, restart mariadb.
Login to mariadb
sudo mysql
Grant access to specific user from a rage of ip subnet
grant all privileges on dbname.* to 'username'@'`192.168.1.%' identified by 'the-password' with grant option;
Then allow firewall:
sudo ufw allow from 192.168.1.0/24 to any port 3306