MySQL - dogtagpki/pki GitHub Wiki

Installation

To install MySQL client:

$ dnf install community-mysql

To install MySQL server from the operating system distribution:

$ dnf install community-mysql-server

To install MySQL from upstream distribution:

$ cat > /etc/yum.repos.d/mysql-community.repo << EOF
[mysql-5.7-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/fc/$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
EOF

Alternatively, download the files directly from upstream repository:

$ dnf localinstall *.rpm

Starting MySQL Server

To start the server:

$ systemctl start mysqld

It will create the initial files in /var/lib/mysql and store the logs in /var/log/mysql.

Enabling MySQL Service

$ systemctl enable mysqld

Connecting to MySQL Server

To connect to a local MySQL server:

$ mysql -u root

To set up SSH tunnel:

$ ssh -N -L 3306:127.0.0.1:3306 <username>@<hostname>

To set up a port forwarding for OpenShift:

$ oc port-forward <pod> 3306

Locking MySQL Database

To lock a database:

$ mysql -u root <database>
mysql> flush tables with read lock;
mysql> set global read_only = ON;
mysql> exit;

Unlocking MySQL Database

To unlock a database:

$ mysql -u root <database>
mysql> set global read_only = OFF;
mysql> unlock tables;
mysql> exit;

Backing Up MySQL Database

$ mysqldump -u root <database> > backup.sql

Restoring MySQL Database

$ mysql -u root -p <database> < backup.sql

See Also

⚠️ **GitHub.com Fallback** ⚠️