Files
mkdocs/docs/macos/webserver/mysql.md
2021-09-15 11:43:35 +02:00

96 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# mysql
#### Connexion à la base wordpress4 par lutilisateur root:
```bash
$ mysql -u root -D wordpress4 -p
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.3.11-MariaDB Homebrew
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [wordpress4]>
```
#### Erreur de syntaxe:
Les commandes doivent se terminer par un **;**
```mysql
MariaDB [(none)]> mysqlcheck zenphoto
->
-> \c
MariaDB [(none)]>
```
Sinon taper **\c** pour revenir.
#### Tache CRON pour maintenance MySQL
```bash
echo "0 4 * * Sun root mysqlcheck -u maintenance --optimize --all-databases" > /etc/cron.d/mysqlcheck
```
```bash
$ mysql_upgrade -u root -ppassword
Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
```
#### BASH : exécuter une requête MySql et exploiter le résultat
```bash
$ echo "SHOW DATABASES;" | mysql -h localhost -u root -ppassword
Database
information_schema
mysql
performance_schema
wordpress
zenphoto
```
[exécuter une requête MySql et exploiter le résultat](https://www.quennec.fr/trucs-astuces/systèmes/gnulinux/utilisation/bash-exécuter-une-requête-mysql-et-exploiter-le-résultat)
#### Créer un utilisateur avec les permissions lecture seule pour le backup des bases.
```mysql
GRANT SELECT, LOCK TABLES ON *.* TO 'MYBACKUPUSER'@'%' IDENTIFIED BY 'MYPASSWORD';
```