Site Tools


mysql

ajouter un user :

root@db1:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 5.7.25-0ubuntu0.18.04.2 (Ubuntu)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> GRANT ALL PRIVILEGES ON *.* TO 'poun'@'192.168.1.130' IDENTIFIED BY 'r3c0mM@nd3';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges ;
Query OK, 0 rows affected (0.00 sec)

mysql> use mysql ;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host, user, plugin, authentication_string, account_locked from user ;
+----------------+------------------+-----------------------+-------------------------------------------+----------------+
| host           | user             | plugin                | authentication_string                     | account_locked |
+----------------+------------------+-----------------------+-------------------------------------------+----------------+
| localhost      | root             | mysql_native_password | *DBD45EC48D50AC1EA7D44E6469199E1F6C7B9D7D | N              |
| localhost      | mysql.session    | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | Y              |
| localhost      | mysql.sys        | mysql_native_password | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | Y              |
| localhost      | debian-sys-maint | mysql_native_password | *33E644A15F3D2E99930A80BF9E3F2CAFFCCAB3E2 | N              |
| localhost      | wpdbuser         | mysql_native_password | *DBD45EC48D50AC1EA7D44E6469199E1F6C7B9D7D | N              |
| 192.168.100.21 | wpdbuser         | mysql_native_password | *DBD45EC48D50AC1EA7D44E6469199E1F6C7B9D7D | N              |
| 192.168.1.130  | poun             | mysql_native_password | *DBD45EC48D50AC1EA7D44E6469199E1F6C7B9D7D | N              |
+----------------+------------------+-----------------------+-------------------------------------------+----------------+
7 rows in set (0.00 sec)

mysql>quit

éditer la conf mysql pour permettre la connection depuis n'importe quelle IP :

root@db1:/etc/mysql/mysql.conf.d# cat /etc/mysql/mysql.conf.d/mysqld.cnf | grep bind
bind-address            = 192.168.100.31
root@db1:/etc/mysql/mysql.conf.d# vi /etc/mysql/mysql.conf.d/mysqld.cnf
root@db1:/etc/mysql/mysql.conf.d# systemctl restart mysql.service
root@db1:/etc/mysql/mysql.conf.d# cat /etc/mysql/mysql.conf.d/mysqld.cnf | grep bind
bind-address            = 0.0.0.0
root@db1:/etc/mysql/mysql.conf.d#
mysql.txt · Last modified: 2019/03/14 12:05 (external edit)