From Dogtag
Revision as of 04:07, 20 September 2022 by Edewata (talk | contribs) (References)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


To install MySQL client:

$ dnf install community-mysql

To install MySQL server:

$ dnf install community-mysql-server
$ systemctl start mysqld
$ systemctl enable mysqld

Get root's temporary password:

$ grep 'temporary password' /var/log/mysqld.log

Initialize MySQL server:

$ mysql_secure_installation

Backup & Restore

To backup a database, first lock the database:

$ mysql -h <hostname> -P <port> -u <username> --password=<password> <database>
mysql> flush tables with read lock;
mysql> set global read_only = ON;
mysql> exit;

Then backup the database:

$ mysqldump -h <hostname> -P <port> -u <username> --password=<password> <database> > database.sql

Then unlock the database:

$ mysql -h <hostname> -P <port> -u <username> --password=<password> <database>
mysql> set global read_only = OFF;
mysql> unlock tables;
mysql> exit;

To restore database:

$ mysql -h <hostname> -P <port> -u <username> --password=<password> <database> < database.sql