ΠΠΎΠ²ΠΎΡΡΡ, ΡΡΠΎ Π»ΡΡΡΠΈΠΉ ΠΏΠ°ΡΠΎΠ»Ρ β ΡΠΎΡ, ΠΊΠΎΡΠΎΡΡΠΉ Π½Π΅ Π½Π°Π΄ΠΎ Π·Π°ΠΏΠΎΠΌΠΈΠ½Π°ΡΡ. Π ΡΠ»ΡΡΠ°Π΅ Ρ MySQL ΡΡΠΎ ΡΠ΅Π°Π»ΡΠ½ΠΎ Π±Π»Π°Π³ΠΎΠ΄Π°ΡΡ ΠΏΠ»Π°Π³ΠΈΠ½Ρ
ΠΠ±Π° ΡΡΠΈ ΠΏΠ»Π°Π³ΠΈΠ½Π° β Π²ΠΎΠ²ΡΠ΅ Π½Π΅ Π½ΠΎΠ²Ρ, ΠΎ Π½ΠΈΡ
ΠΌΠ½ΠΎΠ³ΠΎ Π³ΠΎΠ²ΠΎΡΠΈΠ»ΠΎΡΡ Π² ΡΡΠΎΠΌ ΠΆΠ΅ Π±Π»ΠΎΠ³Π΅, Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ Π² ΡΡΠ°ΡΡΠ΅ ΠΎ ΡΠΎΠΌ,
ΠΠ°ΠΊ Ρ ΡΠΆΠ΅ ΡΠΊΠ°Π·Π°Π», ΡΡΠΎ β Π½Π΅ Π½ΠΎΠ²ΠΎΡΡΠΈ, ΠΈ ΠΊΠΎΠ³Π΄Π° ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΡΡ MySQL, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅ΠΌΡΠ΅ ΠΊΠΎΠΌΠ°Π½Π΄ΠΎΠΉ Debian ΠΏΠ°ΠΊΠ΅ΡΡ .deb, ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ Ρ root-ΠΏΡΠ°Π²Π°ΠΌΠΈ ΡΠΎΠ·Π΄Π°Π΅ΡΡΡ ΠΏΠΎΠ΄ Π°ΡΡΠ΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΈΡ ΡΠ΅ΡΠ΅Π· ΡΠΎΠΊΠ΅Ρ. ΠΡΠΎ ΡΠΏΡΠ°Π²Π΅Π΄Π»ΠΈΠ²ΠΎ ΠΊΠ°ΠΊ Π΄Π»Ρ MySQL, ΡΠ°ΠΊ ΠΈ Π΄Π»Ρ MariaDB.
root@app:~# apt-cache show mysql-server-5.7 | grep -i maintainers
Original-Maintainer: Debian MySQL Maintainers <[email protected]>
Original-Maintainer: Debian MySQL Maintainers <<a href="mailto:[email protected]">[email protected]</a>>
Π‘ ΠΏΠ°ΠΊΠ΅ΡΠ°ΠΌΠΈ Debian Π΄Π»Ρ MySQL, root ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ Π°ΡΡΠ΅Π½ΡΠΈΡΠΈΡΠΈΡΡΠ΅ΡΡΡ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ:
root@app:~# whoami
root=
root@app:~# mysql
Welcome to the MySQL monitor.Β Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.7.27-0ubuntu0.16.04.1 (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> select user, host, plugin, authentication_string from mysql.user where user = 'root';
+------+-----------+-------------+-----------------------+
| user | hostΒ Β Β | plugin | authentication_string |
+------+-----------+-------------+-----------------------+
| root | localhost | auth_socket | Β Β Β Β Β Β Β Β Β Β Β |
+------+-----------+-------------+-----------------------+
1 row in set (0.01 sec)
Π’ΠΎ ΠΆΠ΅ ΠΈ Π² ΡΠ»ΡΡΠ°Π΅ Ρ ΠΏΠ°ΠΊΠ΅ΡΠΎΠΌ .deb Π΄Π»Ρ MariaDB:
10.0.38-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04
MariaDB [(none)]> show grants;
+------------------------------------------------------------------------------------------------+
| Grants for root@localhostΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β |
+------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED VIA unix_socket WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTIONΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β |
+------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
ΠΠ°ΠΊΠ΅ΡΡ .deb ΠΈΠ· ΠΎΡΠΈΡΠΈΠ°Π»ΡΠ½ΠΎΠ³ΠΎ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΡ Percona ΡΠ°ΠΊΠΆΠ΅ Π½Π°ΡΡΡΠ°ΠΈΠ²Π°ΡΡ Π°ΡΡΠ΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΈΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ Ρ root-ΠΏΡΠ°Π²Π°ΠΌΠΈ ΠΏΠΎΠ΄ auth-socket ΠΈ Π΄Π»Ρ Percona Server. ΠΡΠΈΠ²Π΅Π΄Π΅ΠΌ ΠΏΡΠΈΠΌΠ΅Ρ Ρ
root@app:~# whoami
root
root@app:~# mysql
Welcome to the MySQL monitor.Β Commands end with ; or g.
Your MySQL connection id is 9
Server version: 8.0.16-7 Percona Server (GPL), Release '7', Revision '613e312'
Copyright (c) 2009-2019 Percona LLC and/or its affiliates
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> select user, host, plugin, authentication_string from mysql.user where user ='root';
+------+-----------+-------------+-----------------------+
| user | hostΒ Β Β | plugin | authentication_string |
+------+-----------+-------------+-----------------------+
| root | localhost | auth_socket | Β Β Β Β Β Β Β Β Β Β Β |
+------+-----------+-------------+-----------------------+
1 row in set (0.00 sec)
Π’Π°ΠΊ Π² ΡΠ΅ΠΌ ΠΆΠ΅ ΠΌΠ°Π³ΠΈΡ? ΠΠ»Π°Π³ΠΈΠ½ ΠΏΡΠΎΠ²Π΅ΡΡΠ΅Ρ, ΡΡΠΎ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ Linux ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²ΡΠ΅Ρ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ MySQL, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ ΡΠΎΠΊΠ΅Ρ-ΠΎΠΏΡΠΈΡ SO_PEERCRED β ΡΡΠΎΠ±Ρ ΡΠΎΠ±ΡΠ°ΡΡ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Π΅, Π·Π°ΠΏΡΡΠΊΠ°ΡΡΠ΅ΠΌ ΠΊΠ»ΠΈΠ΅Π½ΡΡΠΊΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ. Π’Π°ΠΊΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ, ΠΏΠ»Π°Π³ΠΈΠ½ ΠΌΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΠΎΠ»ΡΠΊΠΎ Π½Π° ΡΠΈΡΡΠ΅ΠΌΠ°Ρ , ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°ΡΡΠΈΡ ΠΎΠΏΡΠΈΡ SO_PEERCRED, Π²ΡΠΎΠ΄Π΅ ΡΠΎΠΉ ΠΆΠ΅ Linux. Π‘ΠΎΠΊΠ΅Ρ-ΠΎΠΏΡΠΈΡ SO_PEERCRED ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΡΠ·Π½Π°Π²Π°ΡΡ uid ΡΠ²ΡΠ·Π°Π½Π½ΠΎΠ³ΠΎ Ρ ΡΠΎΠΊΠ΅ΡΠΎΠΌ ΠΏΡΠΎΡΠ΅ΡΡΠ°. Π ΠΏΠΎΡΠ»Π΅ ΠΎΠ½ ΡΠΆΠ΅ ΠΏΠΎΠ»ΡΡΠ°Π΅Ρ ΡΠ²ΡΠ·Π°Π½Π½ΠΎΠ΅ Ρ ΡΡΠΈΠΌ uid ΠΈΠΌΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ.
ΠΡΠΈΠ²Π΅Π΄Π΅ΠΌ ΠΏΡΠΈΠΌΠ΅Ρ Ρ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Π΅ΠΌ «vagrant»:
vagrant@mysql1:~$ whoami
vagrant
vagrant@mysql1:~$ mysql
ERROR 1698 (28000): Access denied for user 'vagrant'@'localhost'
ΠΠΎΡΠΊΠΎΠ»ΡΠΊΡ Π² MySQL Π½Π΅Ρ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ «vagrant», Π² Π΄ΠΎΡΡΡΠΏΠ΅ Π½Π°ΠΌ ΠΎΡΠΊΠ°Π·Π°Π½ΠΎ. Π‘ΠΎΠ·Π΄Π°Π΄ΠΈΠΌ ΡΠ°ΠΊΠΎΠ³ΠΎ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ ΠΈ ΠΏΠΎΠ²ΡΠΎΡΠΈΠΌ ΠΏΠΎΠΏΡΡΠΊΡ:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'localhost' IDENTIFIED VIA unix_socket;
Query OK, 0 rows affected (0.00 sec)
vagrant@mysql1:~$ mysql
Welcome to the MariaDB monitor.Β Commands end with ; or g.
Your MariaDB connection id is 45
Server version: 10.0.38-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04
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 [(none)]> show grants;
+---------------------------------------------------------------------------------+
| Grants for vagrant@localhostΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β |
+---------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'vagrant'@'localhost' IDENTIFIED VIA unix_socket |
+---------------------------------------------------------------------------------+
1 row in set (0.00 sec)
ΠΠΎΠ»ΡΡΠΈΠ»ΠΎΡΡ!
ΠΡ, Π° ΠΊΠ°ΠΊ Π½Π°ΡΡΠ΅Ρ Π½Π΅-Debian Π΄ΠΈΡΡΡΠΈΠ±ΡΡΠΈΠ²Π°, Π³Π΄Π΅ ΡΡΠΎ Π½Π΅ ΠΏΡΠ΅Π΄ΡΡΠΌΠΎΡΡΠ΅Π½ΠΎ ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ? ΠΠΎΠΏΡΠΎΠ±ΡΠ΅ΠΌ Percona Server for MySQL 8, ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½Π½ΡΠΉ Π½Π° CentOS 7:
mysql> show variables like '%version%comment';
+-----------------+---------------------------------------------------+
| Variable_name Β | Value Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β |
+-----------------+---------------------------------------------------+
| version_comment | Percona Server (GPL), Release 7, Revision 613e312 |
+-----------------+---------------------------------------------------+
1 row in set (0.01 sec)
mysql> CREATE USER 'percona'@'localhost' IDENTIFIED WITH auth_socket;
ERROR 1524 (HY000): Plugin 'auth_socket' is not loaded
ΠΠ±Π»ΠΎΠΌ. Π§Π΅Π³ΠΎ ΠΆΠ΅ Π½Π΅ Ρ Π²Π°ΡΠΈΠ»ΠΎ? ΠΠ»Π°Π³ΠΈΠ½ Π½Π΅ Π·Π°Π³ΡΡΠΆΠ΅Π½:
mysql> pager grep socket
PAGER set to 'grep socket'
mysql> show plugins;
47 rows in set (0.00 sec)
ΠΠΎΠ±Π°Π²ΠΈΠΌ Π² ΠΏΡΠΎΡΠ΅ΡΡ ΠΏΠ»Π°Π³ΠΈΠ½:
mysql> nopager
PAGER set to stdout
mysql> INSTALL PLUGIN auth_socket SONAME 'auth_socket.so';
Query OK, 0 rows affected (0.00 sec)
mysql> pager grep socket; show plugins;
PAGER set to 'grep socket'
| auth_socket Β Β Β Β Β Β Β Β Β Β | ACTIVE | AUTHENTICATION | auth_socket.so | GPL Β Β |
48 rows in set (0.00 sec)
Π’Π΅ΠΏΠ΅ΡΡ Ρ Π½Π°Ρ Π΅ΡΡΡ Π²ΡΠ΅ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎΠ΅. ΠΠΎΠΏΡΠΎΠ±ΡΠ΅ΠΌ Π΅ΡΠ΅ ΡΠ°Π·ΠΎΠΊ:
mysql> CREATE USER 'percona'@'localhost' IDENTIFIED WITH auth_socket;
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'percona'@'localhost';
Query OK, 0 rows affected (0.01 sec)
Π’Π΅ΠΏΠ΅ΡΡ ΠΌΠΎΠΆΠ½ΠΎ Π²ΠΎΠΉΡΠΈ Π² ΡΠΈΡΡΠ΅ΠΌΡ ΠΏΠΎΠ΄ Π»ΠΎΠ³ΠΈΠ½ΠΎΠΌ «percona».
[percona@ip-192-168-1-111 ~]$ whoami
percona
[percona@ip-192-168-1-111 ~]$ mysql -upercona
Welcome to the MySQL monitor.Β Commands end with ; or g.
Your MySQL connection id is 19
Server version: 8.0.16-7 Percona Server (GPL), Release 7, Revision 613e312
Copyright (c) 2009-2019 Percona LLC and/or its affiliates
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> select user, host, plugin, authentication_string from mysql.user where user ='percona';
+---------+-----------+-------------+-----------------------+
| userΒ Β | host Β | plugin Β | authentication_string |
+---------+-----------+-------------+-----------------------+
| percona | localhost | auth_socket | Β Β Β Β Β Β Β Β Β Β Β |
+---------+-----------+-------------+-----------------------+
1 row in set (0.00 sec)
Π ΡΠ½ΠΎΠ²Π° ΠΏΠΎΠ»ΡΡΠΈΠ»ΠΎΡΡ!
ΠΠΎΠΏΡΠΎΡ: ΠΏΠΎΠ»ΡΡΠΈΡΡΡ Π»ΠΈ Π²ΠΎΠΉΡΠΈ Π² ΡΠΈΡΡΠ΅ΠΌΡ ΠΏΠΎΠ΄ ΡΠ΅ΠΌ ΠΆΠ΅ Π»ΠΎΠ³ΠΈΠ½ΠΎΠΌ percona, Π½ΠΎ ΠΎΡ Π΄ΡΡΠ³ΠΎΠ³ΠΎ ΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ?
[percona@ip-192-168-1-111 ~]$ logout
[root@ip-192-168-1-111 ~]# mysql -upercona
ERROR 1698 (28000): Access denied for user 'percona'@'localhost'
ΠΠ΅Ρ, Π½Π΅ ΠΏΠΎΠ»ΡΡΠΈΡΡΡ.
ΠΡΠ²ΠΎΠ΄
MySQL Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ Π³ΠΈΠ±ΠΊΠ°Ρ Π² Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΡ
Π°ΡΠΏΠ΅ΠΊΡΠ°Ρ
, ΠΎΠ΄ΠΈΠ½ ΠΈΠ· ΠΊΠΎΡΠΎΡΡΡ
β ΠΌΠ΅ΡΠΎΠ΄ Π°ΡΡΠ΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΈΠΈ. ΠΠ°ΠΊ Π²ΠΈΠ΄Π½ΠΎ ΠΈΠ· ΡΡΠΎΠ³ΠΎ ΠΏΠΎΡΡΠ°, Π΄ΠΎΡΡΡΠΏ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ»ΡΡΠΈΡΡ Π±Π΅Π· ΠΏΠ°ΡΠΎΠ»Π΅ΠΉ, Π½Π° ΠΎΡΠ½ΠΎΠ²Π°Π½ΠΈΠΈ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Π΅ΠΉ ΠΠ‘. ΠΡΠΎ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΏΠΎΠ»Π΅Π·Π½ΠΎ ΠΏΡΠΈ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½Π½ΡΡ
ΡΡΠ΅Π½Π°ΡΠΈΡΡ
, ΠΈ ΠΎΠ΄ΠΈΠ½ ΠΈΠ· Π½ΠΈΡ
β ΠΊΠΎΠ³Π΄Π° ΠΌΠΈΠ³ΡΠΈΡΡΠ΅ΡΠ΅ Ρ RDS/Aurora Π½Π° ΠΎΠ±ΡΡΠ½ΡΡ MySQL, ΠΏΠΎΠ»ΡΠ·ΡΡΡΡ
ΠΡΡΠΎΡΠ½ΠΈΠΊ: habr.com