MaJ du 04-02-2021
This commit is contained in:
53
docs/MySQL/password.md
Normal file
53
docs/MySQL/password.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# MySQL Password
|
||||
|
||||
|
||||
|
||||
### Rentrer automatiquement le mot de passe MySQL:
|
||||
|
||||
Stocker le mot de passe dans le `~/.my.cnf`.
|
||||
|
||||
```mysql
|
||||
[client]
|
||||
user=mysqlbackupuser
|
||||
password=xxxxxxxx
|
||||
```
|
||||
|
||||
```bash
|
||||
$ mysql -e "SHOW DATABASES"
|
||||
+--------------------+
|
||||
| Database |
|
||||
+--------------------+
|
||||
| information_schema |
|
||||
| mistral |
|
||||
| mysql |
|
||||
| npg |
|
||||
| performance_schema |
|
||||
| wordpress |
|
||||
| zenphoto |
|
||||
+--------------------+
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Avoir 1 mot de passe par base ou par host:
|
||||
|
||||
Dans le `~/.my.cnf`.
|
||||
|
||||
```mysql
|
||||
[clienthost1] # Note: client + host1
|
||||
user=myuser
|
||||
password=mypass
|
||||
database=dbname
|
||||
host=server.location.com
|
||||
```
|
||||
|
||||
```bash
|
||||
$ mysql --defaults-group-suffix=host1
|
||||
```
|
||||
|
||||
Bonus: créer un alias dans `.profile` (.zshrc...):
|
||||
|
||||
```bash
|
||||
echo 'alias mysql_host1="mysql --defaults-group-suffix=host1"' >> ~/.profile
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user