Difference between revisions of "MySQL"

From Dogtag
Jump to: navigation, search
m (Installation)
m (References)
 
Line 67: Line 67:
 
* [https://github.com/sclorg/mysql-container mysql-container]
 
* [https://github.com/sclorg/mysql-container mysql-container]
 
* [https://docs.openshift.com/enterprise/3.2/using_images/db_images/mysql.html OpenShift 3: MySQL]
 
* [https://docs.openshift.com/enterprise/3.2/using_images/db_images/mysql.html OpenShift 3: MySQL]
 +
* [https://docs.fedoraproject.org/en-US/quick-docs/installing-mysql-mariadb/ Installing MySQL/MariaDB]

Latest revision as of 04:07, 20 September 2022

Installation

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

References