Звезда не активнаЗвезда не активнаЗвезда не активнаЗвезда не активнаЗвезда не активна
 

Установка MySQL с поддержкой PHP 7.3 на сервер с ОС Debian 9

После того, как на сервер с Debian 9 установлен PHP 7.3, можно приступить к установке MySQL с поддержкой PHP 7.3. Сразу отмечу, что данная статья не связанна программированием на языке MySQL, а лишь иллюстрирует процесс установки этой системы управления базами данных на сервер. Всё это делается для поднятия web-сервера в связке NGiNX + Apache и привязана к VSD с установленной Debian версии 9. На других системах (или при других настройках) что-то может выглядеть иначе.



Предварительная подготовка сервера к установке MySQL с поддержкой PHP 7.3

Как обычно, для того, чтобы работать с актуальными версиями программ, установленных на сервере, выполним стандартное обновление списка пакетов репозиториев и установим вышедшие обновления, если таковые найдутся:

  1. apt update
  2. apt upgrade

Установка MySQL с поддержкой PHP 7.3 на сервер

Далее запустим процесс установки MySQL с поддержкой PHP 7.3 на сервер:

root@server:~# apt install mysql-server php-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  default-mysql-server galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl libfcgi-perl
  libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl libjemalloc1 liblwp-mediatypes-perl
  libmariadbclient18 libmpfr4 libreadline5 libsigsegv2 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.1 mariadb-client-core-10.1 mariadb-common
  mariadb-server-10.1 mariadb-server-core-10.1 mysql-common php7.3-mysql rsync socat
Suggested packages:
  gawk-doc libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx mariadb-test
  netcat-openbsd tinyca
The following NEW packages will be installed:
  default-mysql-server galera-3 gawk libaio1 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl libfcgi-perl
  libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl libjemalloc1 liblwp-mediatypes-perl
  libmariadbclient18 libmpfr4 libreadline5 libsigsegv2 libterm-readkey-perl libtimedate-perl liburi-perl mariadb-client-10.1 mariadb-client-core-10.1 mariadb-common
  mariadb-server-10.1 mariadb-server-core-10.1 mysql-common mysql-server php-mysql php7.3-mysql rsync socat
0 upgraded, 37 newly installed, 0 to remove and 0 not upgraded.
Need to get 27.3 MB of archives.
After this operation, 195 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Обращаю внимание, что пакет поддержки MySQL для PHP сразу предлагается установить нужной версии этого языка: php7.3-mysql.

Итак, если всё устраивает, вводим Y, жмём Enter и заканчиваем установку MySQL с поддержкой PHP 7.3 на сервер:

Do you want to continue? [Y/n] Y
Get:1 http://deb.debian.org/debian stretch/main amd64 libmpfr4 amd64 3.1.5-1 [556 kB]
Get:2 http://deb.debian.org/debian stretch/main amd64 libsigsegv2 amd64 2.10-5 [28.9 kB]
Get:3 http://deb.debian.org/debian stretch/main amd64 gawk amd64 1:4.1.4+dfsg-1 [571 kB]
Get:4 https://packages.sury.org/php stretch/main amd64 php7.3-mysql amd64 7.3.5-1+0~20190503093827.38+stretch~1.gbp60a41b [116 kB]
Get:5 http://deb.debian.org/debian stretch/main amd64 mysql-common all 5.8+1.0.2 [5,608 B]
Get:6 http://deb.debian.org/debian stretch/main amd64 mariadb-common all 10.1.38-0+deb9u1 [28.4 kB]
Get:7 http://deb.debian.org/debian stretch/main amd64 galera-3 amd64 25.3.19-2 [955 kB]
Get:8 http://deb.debian.org/debian stretch/main amd64 libdbi-perl amd64 1.636-1+b1 [766 kB]
Get:9 https://packages.sury.org/php stretch/main amd64 php-mysql all 2:7.3+69+0~20190303094804.15+stretch~1.gbp0f7465 [6,162 B]
Get:10 http://deb.debian.org/debian stretch/main amd64 libaio1 amd64 0.3.110-3 [9,412 B]
Get:11 http://deb.debian.org/debian stretch/main amd64 libreadline5 amd64 5.2+dfsg-3+b1 [119 kB]
Get:12 http://deb.debian.org/debian stretch/main amd64 mariadb-client-core-10.1 amd64 10.1.38-0+deb9u1 [5,107 kB]
Get:13 http://deb.debian.org/debian stretch/main amd64 libconfig-inifiles-perl all 2.94-1 [53.4 kB]
Get:14 http://deb.debian.org/debian stretch/main amd64 libjemalloc1 amd64 3.6.0-9.1 [89.8 kB]
Get:15 http://deb.debian.org/debian stretch/main amd64 mariadb-client-10.1 amd64 10.1.38-0+deb9u1 [5,918 kB]
Get:16 http://deb.debian.org/debian stretch/main amd64 mariadb-server-core-10.1 amd64 10.1.38-0+deb9u1 [5,241 kB]
Get:17 http://deb.debian.org/debian stretch/main amd64 rsync amd64 3.1.2-1+deb9u2 [393 kB]
Get:18 http://deb.debian.org/debian stretch/main amd64 socat amd64 1.7.3.1-2+deb9u1 [353 kB]
Get:19 http://deb.debian.org/debian stretch/main amd64 mariadb-server-10.1 amd64 10.1.38-0+deb9u1 [5,344 kB]
Get:20 http://deb.debian.org/debian stretch/main amd64 default-mysql-server all 1.0.2 [3,048 B]
Get:21 http://deb.debian.org/debian stretch/main amd64 libhtml-tagset-perl all 3.20-3 [12.7 kB]
Get:22 http://deb.debian.org/debian stretch/main amd64 liburi-perl all 1.71-1 [88.6 kB]
Get:23 http://deb.debian.org/debian stretch/main amd64 libhtml-parser-perl amd64 3.72-3 [104 kB]
Get:24 http://deb.debian.org/debian stretch/main amd64 libcgi-pm-perl all 4.35-1 [222 kB]
Get:25 http://deb.debian.org/debian stretch/main amd64 libfcgi-perl amd64 0.78-2 [38.2 kB]
Get:26 http://deb.debian.org/debian stretch/main amd64 libcgi-fast-perl all 1:2.12-1 [11.2 kB]
Get:27 http://deb.debian.org/debian stretch/main amd64 libmariadbclient18 amd64 10.1.38-0+deb9u1 [785 kB]
Get:28 http://deb.debian.org/debian stretch/main amd64 libdbd-mysql-perl amd64 4.041-2 [114 kB]
Get:29 http://deb.debian.org/debian stretch/main amd64 libencode-locale-perl all 1.05-1 [13.7 kB]
Get:30 http://deb.debian.org/debian stretch/main amd64 libhtml-template-perl all 2.95-2 [67.1 kB]
Get:31 http://deb.debian.org/debian stretch/main amd64 libtimedate-perl all 2.3000-2 [42.2 kB]
Get:32 http://deb.debian.org/debian stretch/main amd64 libhttp-date-perl all 6.02-1 [10.7 kB]
Get:33 http://deb.debian.org/debian stretch/main amd64 libio-html-perl all 1.001-1 [17.6 kB]
Get:34 http://deb.debian.org/debian stretch/main amd64 liblwp-mediatypes-perl all 6.02-1 [22.1 kB]
Get:35 http://deb.debian.org/debian stretch/main amd64 libhttp-message-perl all 6.11-1 [75.9 kB]
Get:36 http://deb.debian.org/debian stretch/main amd64 libterm-readkey-perl amd64 2.37-1 [27.2 kB]
Get:37 http://deb.debian.org/debian stretch/main amd64 mysql-server amd64 5.5.9999+default [1,706 B]
Fetched 27.3 MB in 2s (9,923 kB/s)
Extracting templates from packages: 100%
Preconfiguring packages ...
Selecting previously unselected package libmpfr4:amd64.
(Reading database ... 30096 files and directories currently installed.)
Preparing to unpack .../libmpfr4_3.1.5-1_amd64.deb ...
Unpacking libmpfr4:amd64 (3.1.5-1) ...
Selecting previously unselected package libsigsegv2:amd64.
Preparing to unpack .../libsigsegv2_2.10-5_amd64.deb ...
Unpacking libsigsegv2:amd64 (2.10-5) ...
Setting up libmpfr4:amd64 (3.1.5-1) ...
Setting up libsigsegv2:amd64 (2.10-5) ...
Selecting previously unselected package gawk.
(Reading database ... 30118 files and directories currently installed.)
Preparing to unpack .../00-gawk_1%3a4.1.4+dfsg-1_amd64.deb ...
Unpacking gawk (1:4.1.4+dfsg-1) ...
Selecting previously unselected package mysql-common.
Preparing to unpack .../01-mysql-common_5.8+1.0.2_all.deb ...
Unpacking mysql-common (5.8+1.0.2) ...
Selecting previously unselected package mariadb-common.
Preparing to unpack .../02-mariadb-common_10.1.38-0+deb9u1_all.deb ...
Unpacking mariadb-common (10.1.38-0+deb9u1) ...
Selecting previously unselected package galera-3.
Preparing to unpack .../03-galera-3_25.3.19-2_amd64.deb ...
Unpacking galera-3 (25.3.19-2) ...
Selecting previously unselected package libdbi-perl.
Preparing to unpack .../04-libdbi-perl_1.636-1+b1_amd64.deb ...
Unpacking libdbi-perl (1.636-1+b1) ...
Selecting previously unselected package libaio1:amd64.
Preparing to unpack .../05-libaio1_0.3.110-3_amd64.deb ...
Unpacking libaio1:amd64 (0.3.110-3) ...
Selecting previously unselected package libreadline5:amd64.
Preparing to unpack .../06-libreadline5_5.2+dfsg-3+b1_amd64.deb ...
Unpacking libreadline5:amd64 (5.2+dfsg-3+b1) ...
Selecting previously unselected package mariadb-client-core-10.1.
Preparing to unpack .../07-mariadb-client-core-10.1_10.1.38-0+deb9u1_amd64.deb ...
Unpacking mariadb-client-core-10.1 (10.1.38-0+deb9u1) ...
Selecting previously unselected package libconfig-inifiles-perl.
Preparing to unpack .../08-libconfig-inifiles-perl_2.94-1_all.deb ...
Unpacking libconfig-inifiles-perl (2.94-1) ...
Selecting previously unselected package libjemalloc1.
Preparing to unpack .../09-libjemalloc1_3.6.0-9.1_amd64.deb ...
Unpacking libjemalloc1 (3.6.0-9.1) ...
Selecting previously unselected package mariadb-client-10.1.
Preparing to unpack .../10-mariadb-client-10.1_10.1.38-0+deb9u1_amd64.deb ...
Unpacking mariadb-client-10.1 (10.1.38-0+deb9u1) ...
Selecting previously unselected package mariadb-server-core-10.1.
Preparing to unpack .../11-mariadb-server-core-10.1_10.1.38-0+deb9u1_amd64.deb ...
Unpacking mariadb-server-core-10.1 (10.1.38-0+deb9u1) ...
Selecting previously unselected package rsync.
Preparing to unpack .../12-rsync_3.1.2-1+deb9u2_amd64.deb ...
Unpacking rsync (3.1.2-1+deb9u2) ...
Selecting previously unselected package socat.
Preparing to unpack .../13-socat_1.7.3.1-2+deb9u1_amd64.deb ...
Unpacking socat (1.7.3.1-2+deb9u1) ...
Setting up mysql-common (5.8+1.0.2) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Setting up mariadb-common (10.1.38-0+deb9u1) ...
update-alternatives: using /etc/mysql/mariadb.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mariadb-server-10.1.
(Reading database ... 30708 files and directories currently installed.)
Preparing to unpack .../00-mariadb-server-10.1_10.1.38-0+deb9u1_amd64.deb ...
Unpacking mariadb-server-10.1 (10.1.38-0+deb9u1) ...
Selecting previously unselected package default-mysql-server.
Preparing to unpack .../01-default-mysql-server_1.0.2_all.deb ...
Unpacking default-mysql-server (1.0.2) ...
Selecting previously unselected package libhtml-tagset-perl.
Preparing to unpack .../02-libhtml-tagset-perl_3.20-3_all.deb ...
Unpacking libhtml-tagset-perl (3.20-3) ...
Selecting previously unselected package liburi-perl.
Preparing to unpack .../03-liburi-perl_1.71-1_all.deb ...
Unpacking liburi-perl (1.71-1) ...
Selecting previously unselected package libhtml-parser-perl.
Preparing to unpack .../04-libhtml-parser-perl_3.72-3_amd64.deb ...
Unpacking libhtml-parser-perl (3.72-3) ...
Selecting previously unselected package libcgi-pm-perl.
Preparing to unpack .../05-libcgi-pm-perl_4.35-1_all.deb ...
Unpacking libcgi-pm-perl (4.35-1) ...
Selecting previously unselected package libfcgi-perl.
Preparing to unpack .../06-libfcgi-perl_0.78-2_amd64.deb ...
Unpacking libfcgi-perl (0.78-2) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../07-libcgi-fast-perl_1%3a2.12-1_all.deb ...
Unpacking libcgi-fast-perl (1:2.12-1) ...
Selecting previously unselected package libmariadbclient18:amd64.
Preparing to unpack .../08-libmariadbclient18_10.1.38-0+deb9u1_amd64.deb ...
Unpacking libmariadbclient18:amd64 (10.1.38-0+deb9u1) ...
Selecting previously unselected package libdbd-mysql-perl.
Preparing to unpack .../09-libdbd-mysql-perl_4.041-2_amd64.deb ...
Unpacking libdbd-mysql-perl (4.041-2) ...
Selecting previously unselected package libencode-locale-perl.
Preparing to unpack .../10-libencode-locale-perl_1.05-1_all.deb ...
Unpacking libencode-locale-perl (1.05-1) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../11-libhtml-template-perl_2.95-2_all.deb ...
Unpacking libhtml-template-perl (2.95-2) ...
Selecting previously unselected package libtimedate-perl.
Preparing to unpack .../12-libtimedate-perl_2.3000-2_all.deb ...
Unpacking libtimedate-perl (2.3000-2) ...
Selecting previously unselected package libhttp-date-perl.
Preparing to unpack .../13-libhttp-date-perl_6.02-1_all.deb ...
Unpacking libhttp-date-perl (6.02-1) ...
Selecting previously unselected package libio-html-perl.
Preparing to unpack .../14-libio-html-perl_1.001-1_all.deb ...
Unpacking libio-html-perl (1.001-1) ...
Selecting previously unselected package liblwp-mediatypes-perl.
Preparing to unpack .../15-liblwp-mediatypes-perl_6.02-1_all.deb ...
Unpacking liblwp-mediatypes-perl (6.02-1) ...
Selecting previously unselected package libhttp-message-perl.
Preparing to unpack .../16-libhttp-message-perl_6.11-1_all.deb ...
Unpacking libhttp-message-perl (6.11-1) ...
Selecting previously unselected package libterm-readkey-perl.
Preparing to unpack .../17-libterm-readkey-perl_2.37-1_amd64.deb ...
Unpacking libterm-readkey-perl (2.37-1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../18-mysql-server_5.5.9999+default_amd64.deb ...
Unpacking mysql-server (5.5.9999+default) ...
Selecting previously unselected package php7.3-mysql.
Preparing to unpack .../19-php7.3-mysql_7.3.5-1+0~20190503093827.38+stretch~1.gbp60a41b_amd64.deb ...
Unpacking php7.3-mysql (7.3.5-1+0~20190503093827.38+stretch~1.gbp60a41b) ...
Selecting previously unselected package php-mysql.
Preparing to unpack .../20-php-mysql_2%3a7.3+69+0~20190303094804.15+stretch~1.gbp0f7465_all.deb ...
Unpacking php-mysql (2:7.3+69+0~20190303094804.15+stretch~1.gbp0f7465) ...
Setting up libhtml-tagset-perl (3.20-3) ...
Setting up libconfig-inifiles-perl (2.94-1) ...
Setting up libencode-locale-perl (1.05-1) ...
Setting up libjemalloc1 (3.6.0-9.1) ...
Setting up libtimedate-perl (2.3000-2) ...
Setting up socat (1.7.3.1-2+deb9u1) ...
Setting up libio-html-perl (1.001-1) ...
Setting up libmariadbclient18:amd64 (10.1.38-0+deb9u1) ...
Setting up gawk (1:4.1.4+dfsg-1) ...
Setting up libterm-readkey-perl (2.37-1) ...
Setting up rsync (3.1.2-1+deb9u2) ...
Created symlink /etc/systemd/system/multi-user.target.wants/rsync.service → /lib/systemd/system/rsync.service.
Processing triggers for libapache2-mod-php7.3 (7.3.5-1+0~20190503093827.38+stretch~1.gbp60a41b) ...
Setting up liblwp-mediatypes-perl (6.02-1) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Setting up libaio1:amd64 (0.3.110-3) ...
Setting up galera-3 (25.3.19-2) ...
Setting up liburi-perl (1.71-1) ...
Setting up php7.3-mysql (7.3.5-1+0~20190503093827.38+stretch~1.gbp60a41b) ...

Creating config file /etc/php/7.3/mods-available/mysqlnd.ini with new version

Creating config file /etc/php/7.3/mods-available/mysqli.ini with new version

Creating config file /etc/php/7.3/mods-available/pdo_mysql.ini with new version
Processing triggers for systemd (232-25+deb9u11) ...
Setting up libhtml-parser-perl (3.72-3) ...
Setting up libcgi-pm-perl (4.35-1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up libreadline5:amd64 (5.2+dfsg-3+b1) ...
Setting up libfcgi-perl (0.78-2) ...
Setting up php-mysql (2:7.3+69+0~20190303094804.15+stretch~1.gbp0f7465) ...
Setting up libdbi-perl (1.636-1+b1) ...
Setting up libhttp-date-perl (6.02-1) ...
Setting up mariadb-server-core-10.1 (10.1.38-0+deb9u1) ...
Setting up libhtml-template-perl (2.95-2) ...
Setting up mariadb-client-core-10.1 (10.1.38-0+deb9u1) ...
Setting up libcgi-fast-perl (1:2.12-1) ...
Setting up libhttp-message-perl (6.11-1) ...
Setting up libdbd-mysql-perl (4.041-2) ...
Setting up mariadb-client-10.1 (10.1.38-0+deb9u1) ...
Setting up mariadb-server-10.1 (10.1.38-0+deb9u1) ...
Created symlink /etc/systemd/system/mysql.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /lib/systemd/system/mariadb.service.
Setting up default-mysql-server (1.0.2) ...
Setting up mysql-server (5.5.9999+default) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Processing triggers for libapache2-mod-php7.3 (7.3.5-1+0~20190503093827.38+stretch~1.gbp60a41b) ...
Processing triggers for systemd (232-25+deb9u11) ...

Если просмотреть лог установки, то можно заметить, что установилась MariaDB в качестве mysql.service. То есть, всё в порядке, разработчики позаботились о том, чтобы устанавливались последние разработки, которые рекомендуются в качестве флагманских.

Проверка версии установленного MySQL

Убедимся в том, что же за MySQL установился на сервере:

root@server:~# mysql --version
mysql  Ver 15.1 Distrib 10.1.38-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Ниже не нужно — осталось от экспериментов


Установка пароля суперпользователя root для MariaDB

Лично меня эта «тихая» установка настораживает. Пароль суперпользователя root ни разу не спросили, и кто его знает, установили ли его вообще. Лучше перестраховаться и задать этот пароль жёстко. Для этого нужно ввести команду:

root@server:~# mysql -u root -p

После этого система попросит ввести пароль для root. Его следует ввести (вслепую) и нажать Enter. После этого система выдаст приглашение:

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 10.1.38-MariaDB-0+deb9u1 Debian 9.8

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)]>

Зададим пароль командой:

UPDATE mysql.user SET authentication_string = PASSWORD('ТУТ_НОВЫЙ_ПАРОЛЬ')WHERE User = 'root' AND Host = 'localhost';FLUSH PRIVILEGES;

Если всё прошло удачно, система выдаст подтверждение о том, что пароль успешно изменён:

MariaDB [(none)]> UPDATE mysql.user SET authentication_string = PASSWORD('ТУТ_НОВЫЙ_ПАРОЛЬ')WHERE User = 'root' AND Host = 'localhost';FLUSH PRIVILEGES;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

Query OK, 0 rows affected (0.00 sec)

 

На этом установку MySQL с поддержкой PHP 7.3 на сервер с ОС Debian 9 можно считать завершённой.

Для выхода из режима работы с MySQL нужно воспользоваться командой \q.

Заберите ссылку на статью к себе, чтобы потом легко её найти ;)

Выберите, то, чем пользуетесь чаще всего:

Спасибо за внимание, оставайтесь на связи! Ниже ссылка на форум и обсуждение ; )


Обсудить эту статью

INFO: Вы отправляете сообщение как 'Гость'