# Installer mysql

### Installation:

```bash
$ brew update
$ brew install mariadb
$ brew services start mariadb
```

<u>MariaDb est installé ici:</u>

Mac intel:

`/usr/local/Cellar/mariadb/10.2.11`

Mac M1:

`/opt/homebrew/Cellar/mariadb/10.6.4`

### Sécuriser l'installation:

```bash
$ sudo /opt/homebrew/bin/mysql_secure_installation

mysql -u root -p
Enter password:
```

### Arrêter MySQL:

```bash
$ brew services stop mariadb
```

### Démarrer MySQL:

```bash
$ brew services start mariadb
ou
$ mysql.server start
```

### Fix the 2002 MySQL Socket error:

```bash
$ sudo mkdir /var/mysql
$ sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
```

### Version:

```bash
$ mysql -v -u root -p
```

### Après une m-à-j:

arrêter puis démarrer

### Bases:

Les bases sont stockées ici: `/usr/local/var/mysql`

### Fichier de configuration:

my.cnf:

```
#osx (Homebrew): /usr/local/etc/my.cnf

[mysqld]
#innodb_force_recovery = 1
```

### Erreurs:

```bash
$ mysql -v -u root -p
mysql: Can't read dir of '/usr/local/etc/my.cnf.d' (Errcode: 2 "No such file or directory")
Fatal error in defaults handling. Program aborted
```

Le répertoire `/usr/local/etc/my.cnf.d` n'existe plus, il faut le recréer et y créer un fichier:

```bash
$ mkdir /usr/local/etc/my.cnf.d
$ touch wont_prune.txt
```



Les fichiers [logs](https://dev.mysql.com/doc/refman/5.7/en/server-logs.html) (domain.err) sont avec les bases:

```bash
#osx (Homebrew):

$ cd /usr/local/var/mysql
total 388560
drwxr-xr-x  32 bruno  admin      1024 28 nov 16:53 .
drwxrwxr-x  13 bruno  admin       416 16 fév  2018 ..
-rw-rw----   1 bruno  admin     16384 28 nov 08:08 aria_log.00000001
-rw-rw----   1 bruno  admin        52 28 nov 08:08 aria_log_control
drwx------  48 bruno  admin      1536  1 déc 17:05 funnymac
drwx------  53 bruno  admin      1696  1 déc 17:05 ghost_prod
-rw-r-----   1 bruno  admin     15114 28 nov 08:08 ib_buffer_pool
-rw-rw----   1 bruno  admin  50331648  3 déc 07:19 ib_logfile0
-rw-rw----   1 bruno  admin  50331648 24 oct 12:51 ib_logfile1
-rw-rw----   1 bruno  admin  79691776  3 déc 07:19 ibdata1
-rw-rw----   1 bruno  admin  12582912 28 nov 16:53 ibtmp1
-rw-rw----   1 bruno  admin         0 24 jul  2017 multi-master.info
drwx------  89 bruno  admin      2848  1 déc 17:05 mysql
drwx------   3 bruno  admin        96 24 jul  2017 performance_schema
drwx------  41 bruno  admin      1312  1 déc 17:05 phpmyadmin
-rw-rw----   1 bruno  admin   1271878  3 déc 07:19 silverbook.home.err
-rw-rw----   1 bruno  admin         5 28 nov 16:53 silverbook.home.pid
```



### Liens:

[:fa-link: https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/ ](https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/)

[:fa-link: https://coolestguidesontheplanet.com/how-to-change-the-mysql-root-password/ ](https://coolestguidesontheplanet.com/how-to-change-the-mysql-root-password/)

[:fa-link: http://apple.stackexchange.com/questions/255671/error-mysql-server-pid-file-could-not-be-found](http://apple.stackexchange.com/questions/255671/error-mysql-server-pid-file-could-not-be-found)



### Package MySQL

[:fa-link: Télécharger depuis mysql.com](http://dev.mysql.com/downloads/mysql/)

[:fa-link: Installation](https://dev.mysql.com/doc/refman/5.7/en/osx-installation.html)

### 