useful:mysql-mariadb
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
useful:mysql-mariadb [2022/08/13 06:36] – admin | useful:mysql-mariadb [2024/12/02 16:49] (current) – admin | ||
---|---|---|---|
Line 2: | Line 2: | ||
====== MySQL / MariaDB ====== | ====== MySQL / MariaDB ====== | ||
+ | |||
+ | ===== Set up replication ===== | ||
+ | |||
+ | This is the command to set everything: | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | where the numbers 000673 and 4 will need to be changed. | ||
+ | |||
+ | ===== Resync replication ===== | ||
+ | |||
+ | This deserves [[useful: | ||
===== Log all queries ===== | ===== Log all queries ===== | ||
Line 44: | Line 57: | ||
Edit / | Edit / | ||
- | sudo systemd | + | sudo systemctl |
sudo systemctl start mysql # and it should finally start | sudo systemctl start mysql # and it should finally start | ||
+ | ===== SSH Tunnel to Database ===== | ||
+ | |||
+ | If the MySQL or MariaDB database is running on a different machine (whether real or virtual) from the application, | ||
+ | |||
+ | Various alternatives exist, the main ones being and SSH tunnel, TLS connection, VPN. Of these, the SSH tunnel is the easiest to configure, and also the most efficient. | ||
+ | |||
+ | I used to set up SSH tunnels with autossh which provides a means of restarting SSH if it should fail. More recently, I found that it is possible in systems that support systemd to run the tunnel as a service. The service mechanism will handle the restarting without the need for extra software. The creation of tunnels can also be made quite elegant. | ||
+ | |||
+ | The solution I have now used is well described at [[https:// | ||
+ | |||
+ | Except that I had a big problem with one connection, and it seems the fix is to change " | ||
+ | |||
+ | |||
+ | ===== Data files under /home directory ===== | ||
+ | |||
+ | By default, this is not allowed and will cause errors. But there are situations where /home is a good place for the data. To fix this in Debian, create and edit this file: | ||
+ | |||
+ | vim / | ||
+ | |||
+ | Set the contents to: | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | It should be possible to achieve this without knowing exactly where the file is by using: | ||
+ | |||
+ | | ||
+ | |||
+ | but when I tried, it seemed not to work. | ||
+ | |||
+ | ===== Change collation for all tables in a database ===== | ||
+ | |||
+ | Remember to set the correct name for the database in this code and make sure output file does not exist: | ||
+ | |||
+ | SET @MY_SCHEMA = " | ||
+ | | ||
+ | CONCAT(" | ||
+ | FROM INFORMATION_SCHEMA.TABLES | ||
+ | WHERE TABLE_SCHEMA=@MY_SCHEMA | ||
+ | AND TABLE_TYPE=" | ||
+ | INTO OUTFILE '/ | ||
+ | |||
+ | Then run this command (changing database name as appropriate): | ||
+ | |||
+ | mysql myremos_j41 < / | ||
+ | |||
+ | ===== Get basename or dirname from a file path or similar ===== | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | ===== Create a new root user ===== | ||
+ | |||
+ | | ||
+ | GRANT ALL PRIVILEGES ON *.* TO ' | ||
useful/mysql-mariadb.1660372576.txt.gz · Last modified: 2022/08/13 06:36 by admin