دوی وايي چې غوره پاسورډ هغه دی چې تاسو باید په یاد ولرئ. د MySQL په قضیه کې دا د پلگ ان څخه مننه امکان لري
دا دواړه پلگ ان بالکل نوي ندي؛ په ورته بلاګ کې د دوی په اړه ډیر څه ویل شوي ، د مثال په توګه په مقاله کې
لکه څنګه چې ما وویل، دا خبر ندی، او کله چې د ډیبیان ټیم لخوا ملاتړ شوي د .deb کڅوړو په کارولو سره MySQL نصب کول، د ساکټ تصدیق لپاره د روټ کاروونکي رامینځته کیږي. دا د 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>>
د MySQL لپاره د Debian کڅوړو سره، د روټ کاروونکي په لاندې ډول تصدیق شوي:
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 کڅوړې سره ورته قضیه ده:
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 ذخیره څخه هم د روټ کارونکي تصدیق د auth-saket لاندې او د Percona سرور لپاره تنظیموي. راځئ چې یو مثال ورکړو
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)
نو جادو څه شی دی؟ پلگ ان ګوري چې د لینکس کارونکي د SO_PEERCRED ساکټ اختیار په کارولو سره د مای ایس کیو ایل کارونکي سره سمون لري ترڅو د پیرودونکي برنامه پرمخ وړونکي کارونکي په اړه معلومات راټول کړي. په دې توګه، پلگ ان یوازې په سیسټمونو کې کارول کیدی شي چې د SO_PEERCRED اختیار ملاتړ کوي، لکه لینکس. د SO_PEERCRED ساکټ اختیار تاسو ته اجازه درکوي چې د ساکټ سره تړلې پروسې uid ومومئ. او بیا هغه دمخه د دې uid سره تړلی کارن نوم ترلاسه کوي.
دلته د کارونکي "vagrant" سره یو مثال دی:
vagrant@mysql1:~$ whoami
vagrant
vagrant@mysql1:~$ mysql
ERROR 1698 (28000): Access denied for user 'vagrant'@'localhost'
له هغه ځایه چې په MySQL کې هیڅ "واګرنټ" کارن شتون نلري، موږ د لاسرسي څخه منع شوي یو. راځئ چې داسې یو کارن جوړ کړو او بیا هڅه وکړو:
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)
پېښ شول!
ښه ، د غیر دیبیان توزیع په اړه څه شی چیرې چې دا د ډیفالټ لخوا ندي چمتو شوي؟ راځئ چې په CentOS 8 کې نصب شوي MySQL 7 لپاره Percona سرور هڅه وکړو:
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@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@ip-192-168-1-111 ~]$ logout
[root@ip-192-168-1-111 ~]# mysql -upercona
ERROR 1698 (28000): Access denied for user 'percona'@'localhost'
نه ، دا کار نه کوي
پایلې
MySQL په څو اړخونو کې خورا انعطاف منونکی دی، چې یو یې د تصدیق کولو طریقه ده. لکه څنګه چې تاسو د دې پوسټ څخه لیدلی شئ، د OS کاروونکو پراساس، د پاسورډونو پرته لاسرسی ترلاسه کیدی شي. دا په ځینو سناریوګانو کې ګټور کیدی شي، او یو یې هغه وخت دی کله چې د RDS/Aurora څخه منظم MySQL ته لیږدول کیږي
سرچینه: www.habr.com