Translated using Weblate (Estonian)
[phpmyadmin.git] / doc / setup.rst
blobb6c82ee7d9edc71d3c733c70dce4a860e710bc7c
1 .. _setup:
3 Installation
4 ============
6 phpMyAdmin does not apply any special security methods to the MySQL
7 database server. It is still the system administrator's job to grant
8 permissions on the MySQL databases properly. phpMyAdmin's :guilabel:`Users`
9 page can be used for this.
11 .. warning::
13     :term:`Mac` users should note that if you are on a version before
14     :term:`Mac OS X`, StuffIt unstuffs with :term:`Mac` formats. So you'll have
15     to resave as in BBEdit to Unix style ALL phpMyAdmin scripts before
16     uploading them to your server, as PHP seems not to like :term:`Mac`-style
17     end of lines character ("``\r``").
19 Linux distributions
20 +++++++++++++++++++
22 phpMyAdmin is included in most Linux distributions. It is recommended to use
23 distribution packages when possible - they usually provide integration to your
24 distribution and you will automatically get security updates from your distribution.
26 .. _debian-package:
28 Debian
29 ------
31 Debian's package repositories include a phpMyAdmin package, but be aware that
32 the configuration file is maintained in ``/etc/phpmyadmin`` and may differ in
33 some ways from the official phpMyAdmin documentation. Specifically it does:
35 * Configuration of web server (works for Apache and lighttpd).
36 * Creating of :ref:`linked-tables` using dbconfig-common.
37 * Securing setup script, see :ref:`debian-setup`.
39 .. seealso::
41     More information can be found in `README.Debian <https://salsa.debian.org/phpmyadmin-team/phpmyadmin/blob/master/debian/README.Debian>`_
42     (it is installed as :file:`/usr/share/doc/phmyadmin/README.Debian` with the package).
44 OpenSUSE
45 --------
47 OpenSUSE already comes with phpMyAdmin package, just install packages from
48 the `openSUSE Build Service <https://software.opensuse.org/package/phpMyAdmin>`_.
50 Ubuntu
51 ------
53 Ubuntu ships phpMyAdmin package, however if you want to use recent version, you
54 can use packages from
55 `phpMyAdmin PPA <https://launchpad.net/~nijel/+archive/ubuntu/phpmyadmin>`_.
57 .. seealso::
59     The packages are same as in :ref:`debian-package` please check the documentation
60     there for more details.
62 Gentoo
63 ------
65 Gentoo ships the phpMyAdmin package, both in a near stock configuration as well
66 as in a ``webapp-config`` configuration. Use ``emerge dev-db/phpmyadmin`` to
67 install.
69 Mandriva
70 --------
72 Mandriva ships the phpMyAdmin package in their ``contrib`` branch and can be
73 installed via the usual Control Center.
75 Fedora
76 ------
78 Fedora ships the phpMyAdmin package, but be aware that the configuration file
79 is maintained in ``/etc/phpMyAdmin/`` and may differ in some ways from the
80 official phpMyAdmin documentation.
82 Red Hat Enterprise Linux
83 ------------------------
85 Red Hat Enterprise Linux itself and thus derivatives like CentOS don't
86 ship phpMyAdmin, but the Fedora-driven repository
87 `Extra Packages for Enterprise Linux (EPEL) <https://fedoraproject.org/wiki/EPEL>`_
88 is doing so, if it's
89 `enabled <https://fedoraproject.org/wiki/EPEL/FAQ#howtouse>`_.
90 But be aware that the configuration file is maintained in
91 ``/etc/phpMyAdmin/`` and may differ in some ways from the
92 official phpMyAdmin documentation.
94 Installing on Windows
95 +++++++++++++++++++++
97 The easiest way to get phpMyAdmin on Windows is using third party products
98 which include phpMyAdmin together with a database and web server such as
99 `XAMPP <https://www.apachefriends.org/>`_.
101 You can find more of such options at `Wikipedia <https://en.wikipedia.org/wiki/List_of_AMP_packages>`_.
103 Installing from Git
104 +++++++++++++++++++
106 You can clone current phpMyAdmin source from
107 ``https://github.com/phpmyadmin/phpmyadmin.git``:
109 .. code-block:: sh
111     git clone https://github.com/phpmyadmin/phpmyadmin.git
113 Additionally you need to install dependencies using the `Composer tool`_:
115 .. code-block:: sh
117     composer update
119 If you do not intend to develop, you can skip the installation of developer tools
120 by invoking:
122 .. code-block:: sh
124     composer update --no-dev
126 .. _composer:
128 Installing using Composer
129 +++++++++++++++++++++++++
131 You can install phpMyAdmin using the `Composer tool`_, since 4.7.0 the releases
132 are automatically mirrored to the default `Packagist`_ repository.
134 .. note::
136     The content of the Composer repository is automatically generated
137     separately from the releases, so the content doesn't have to be
138     100% same as when you download the tarball. There should be no
139     functional differences though.
141 To install phpMyAdmin simply run:
143 .. code-block:: sh
145     composer create-project phpmyadmin/phpmyadmin
147 Alternatively you can use our own composer repository, which contains
148 the release tarballs and is available at
149 <https://www.phpmyadmin.net/packages.json>:
151 .. code-block:: sh
153     composer create-project phpmyadmin/phpmyadmin --repository-url=https://www.phpmyadmin.net/packages.json --no-dev
155 .. _docker:
157 Installing using Docker
158 +++++++++++++++++++++++
160 phpMyAdmin comes with a `Docker image`_, which you can easily deploy. You can
161 download it using:
163 .. code-block:: sh
165     docker pull phpmyadmin/phpmyadmin
167 The phpMyAdmin server will listen on port 80. It supports several ways of
168 configuring the link to the database server, either by Docker's link feature
169 by linking your database container to ``db`` for phpMyAdmin (by specifying
170 ``--link your_db_host:db``) or by environment variables (in this case it's up
171 to you to set up networking in Docker to allow the phpMyAdmin container to access
172 the database container over network).
174 .. _docker-vars:
176 Docker environment variables
177 ----------------------------
179 You can configure several phpMyAdmin features using environment variables:
181 .. envvar:: PMA_ARBITRARY
183     Allows you to enter a database server hostname on login form.
185     .. seealso:: :config:option:`$cfg['AllowArbitraryServer']`
187 .. envvar:: PMA_HOST
189     Host name or IP address of the database server to use.
191     .. seealso:: :config:option:`$cfg['Servers'][$i]['host']`
193 .. envvar:: PMA_HOSTS
195     Comma-separated host names or IP addresses of the database servers to use.
197     .. note:: Used only if :envvar:`PMA_HOST` is empty.
199 .. envvar:: PMA_VERBOSE
201     Verbose name of the database server.
203     .. seealso:: :config:option:`$cfg['Servers'][$i]['verbose']`
205 .. envvar:: PMA_VERBOSES
207     Comma-separated verbose name of the database servers.
209     .. note:: Used only if :envvar:`PMA_VERBOSE` is empty.
211 .. envvar:: PMA_USER
213     User name to use for :ref:`auth_config`.
215 .. envvar:: PMA_PASSWORD
217     Password to use for :ref:`auth_config`.
219 .. envvar:: PMA_PORT
221     Port of the database server to use.
223 .. envvar:: PMA_PORTS
225     Comma-separated ports of the database server to use.
227     .. note:: Used only if :envvar:`PMA_PORT` is empty.
229 .. envvar:: PMA_ABSOLUTE_URI
231     The fully-qualified path (``https://pma.example.net/``) where the reverse
232     proxy makes phpMyAdmin available.
234     .. seealso:: :config:option:`$cfg['PmaAbsoluteUri']`
236 By default, :ref:`cookie` is used, but if :envvar:`PMA_USER` and
237 :envvar:`PMA_PASSWORD` are set, it is switched to :ref:`auth_config`.
239 .. note::
241     The credentials you need to log in are stored in the MySQL server, in case
242     of Docker image there are various ways to set it (for example
243     :samp:`MYSQL_ROOT_PASSWORD` when starting the MySQL container). Please check
244     documentation for `MariaDB container <https://hub.docker.com/r/_/mariadb/>`_
245     or `MySQL container <https://hub.docker.com/r/_/mysql/>`_.
247 .. _docker-custom:
249 Customizing configuration
250 -------------------------
252 Additionally configuration can be tweaked by :file:`/etc/phpmyadmin/config.user.inc.php`. If
253 this file exists, it will be loaded after configuration is generated from above
254 environment variables, so you can override any configuration variable. This
255 configuration can be added as a volume when invoking docker using
256 `-v /some/local/directory/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php` parameters.
258 Note that the supplied configuration file is applied after :ref:`docker-vars`,
259 but you can override any of the values.
261 For example to change default behaviour of CSV export you can use following
262 configuration file:
264 .. code-block:: php
266     <?php
267     $cfg['Export']['csv_columns'] = true;
268     ?>
270 You can also use it to define server configuration instead of using the
271 environment variables listed in :ref:`docker-vars`:
273 .. code-block:: php
275     <?php
276     /* Override Servers array */
277     $cfg['Servers'] = [
278         1 => [
279             'auth_type' => 'cookie',
280             'host' => 'mydb1',
281             'port' => 3306,
282             'verbose' => 'Verbose name 1',
283         ],
284         2 => [
285             'auth_type' => 'cookie',
286             'host' => 'mydb2',
287             'port' => 3306,
288             'verbose' => 'Verbose name 2',
289         ],
290     ];
292 .. seealso::
294     See :ref:`config` for detailed description of configuration options.
296 Docker Volumes
297 --------------
299 You can use following volumes to customize image behavior:
301 :file:`/etc/phpmyadmin/config.user.inc.php`
303     Can be used for additional settings, see previous chapter for more details.
305 :file:`/sessions/`
307     Directory where PHP sessions are stored. You might want to share this
308     for example when using :ref:`auth_signon`.
310 :file:`/www/themes/`
312     Directory where phpMyAdmin looks for themes. By default only those shipped
313     with phpMyAdmin are included, but you can include additional phpMyAdmin
314     themes (see :ref:`themes`) by using Docker volumes.
316 Docker Examples
317 ---------------
319 To connect phpMyAdmin to a given server use:
321 .. code-block:: sh
323     docker run --name myadmin -d -e PMA_HOST=dbhost -p 8080:80 phpmyadmin/phpmyadmin
325 To connect phpMyAdmin to more servers use:
327 .. code-block:: sh
329     docker run --name myadmin -d -e PMA_HOSTS=dbhost1,dbhost2,dbhost3 -p 8080:80 phpmyadmin/phpmyadmin
331 To use arbitrary server option:
333 .. code-block:: sh
335     docker run --name myadmin -d --link mysql_db_server:db -p 8080:80 -e PMA_ARBITRARY=1 phpmyadmin/phpmyadmin
337 You can also link the database container using Docker:
339 .. code-block:: sh
341     docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 phpmyadmin/phpmyadmin
343 Running with additional configuration:
345 .. code-block:: sh
347     docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 -v /some/local/directory/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php phpmyadmin/phpmyadmin
349 Running with additional themes:
351 .. code-block:: sh
353     docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 -v /custom/phpmyadmin/theme/:/www/themes/theme/ phpmyadmin/phpmyadmin
355 Using docker-compose
356 --------------------
358 Alternatively you can also use docker-compose with the docker-compose.yml from
359 <https://github.com/phpmyadmin/docker>.  This will run phpMyAdmin with an
360 arbitrary server - allowing you to specify MySQL/MariaDB server on login page.
362 .. code-block:: sh
364     docker-compose up -d
366 Customizing configuration file using docker-compose
367 ---------------------------------------------------
369 You can use an external file to customize phpMyAdmin configuration and pass it
370 using the volumes directive:
372 .. code-block:: yaml
374     phpmyadmin:
375         image: phpmyadmin/phpmyadmin
376         container_name: phpmyadmin
377         environment:
378          - PMA_ARBITRARY=1
379         restart: always
380         ports:
381          - 8080:80
382         volumes:
383          - /sessions
384          - ~/docker/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
385          - /custom/phpmyadmin/theme/:/www/themes/theme/
387 .. seealso:: :ref:`docker-custom`
389 Running behind haproxy in a subdirectory
390 ----------------------------------------
392 When you want to expose phpMyAdmin running in a Docker container in a
393 subdirectory, you need to rewrite the request path in the server proxying the
394 requests.
396 For example using haproxy it can be done as:
398 .. code-block:: text
400     frontend http
401         bind *:80
402         option forwardfor
403         option http-server-close
405         ### NETWORK restriction
406         acl LOCALNET  src 10.0.0.0/8 192.168.0.0/16 172.16.0.0/12
408         # /phpmyadmin
409         acl phpmyadmin  path_dir /phpmyadmin
410         use_backend phpmyadmin if phpmyadmin LOCALNET
412     backend phpmyadmin
413         mode http
415         reqirep  ^(GET|POST|HEAD)\ /phpmyadmin/(.*)     \1\ /\2
417         # phpMyAdmin container IP
418         server localhost     172.30.21.21:80
420 When using traefik, something like following should work:
422 .. code-block:: text
424     defaultEntryPoints = ["http"]
425     [entryPoints]
426       [entryPoints.http]
427       address = ":80"
428         [entryPoints.http.redirect]
429           regex = "(http:\\/\\/[^\\/]+\\/([^\\?\\.]+)[^\\/])$"
430           replacement = "$1/"
432     [backends]
433       [backends.myadmin]
434         [backends.myadmin.servers.myadmin]
435         url="http://internal.address.to.pma"
437     [frontends]
438        [frontends.myadmin]
439        backend = "myadmin"
440        passHostHeader = true
441          [frontends.myadmin.routes.default]
442          rule="PathPrefixStrip:/phpmyadmin/;AddPrefix:/"
444 You then should specify :envvar:`PMA_ABSOLUTE_URI` in the docker-compose
445 configuration:
447 .. code-block:: yaml
449     version: '2'
451     services:
452       phpmyadmin:
453         restart: always
454         image: phpmyadmin/phpmyadmin
455         container_name: phpmyadmin
456         hostname: phpmyadmin
457         domainname: example.com
458         ports:
459           - 8000:80
460         environment:
461           - PMA_HOSTS=172.26.36.7,172.26.36.8,172.26.36.9,172.26.36.10
462           - PMA_VERBOSES=production-db1,production-db2,dev-db1,dev-db2
463           - PMA_USER=root
464           - PMA_PASSWORD=
465           - PMA_ABSOLUTE_URI=http://example.com/phpmyadmin/
467 .. _quick_install:
469 Quick Install
470 +++++++++++++
472 #. Choose an appropriate distribution kit from the phpmyadmin.net
473    Downloads page. Some kits contain only the English messages, others
474    contain all languages. We'll assume you chose a kit whose name
475    looks like ``phpMyAdmin-x.x.x -all-languages.tar.gz``.
476 #. Ensure you have downloaded a genuine archive, see :ref:`verify`.
477 #. Untar or unzip the distribution (be sure to unzip the subdirectories):
478    ``tar -xzvf phpMyAdmin_x.x.x-all-languages.tar.gz`` in your
479    webserver's document root. If you don't have direct access to your
480    document root, put the files in a directory on your local machine,
481    and, after step 4, transfer the directory on your web server using,
482    for example, ftp.
483 #. Ensure that all the scripts have the appropriate owner (if PHP is
484    running in safe mode, having some scripts with an owner different from
485    the owner of other scripts will be a problem). See :ref:`faq4_2` and
486    :ref:`faq1_26` for suggestions.
487 #. Now you must configure your installation. There are two methods that
488    can be used. Traditionally, users have hand-edited a copy of
489    :file:`config.inc.php`, but now a wizard-style setup script is provided
490    for those who prefer a graphical installation. Creating a
491    :file:`config.inc.php` is still a quick way to get started and needed for
492    some advanced features.
494 Manually creating the file
495 --------------------------
497 To manually create the file, simply use your text editor to create the
498 file :file:`config.inc.php` (you can copy :file:`config.sample.inc.php` to get
499 a minimal configuration file) in the main (top-level) phpMyAdmin
500 directory (the one that contains :file:`index.php`). phpMyAdmin first
501 loads :file:`libraries/config.default.php` and then overrides those values
502 with anything found in :file:`config.inc.php`. If the default value is
503 okay for a particular setting, there is no need to include it in
504 :file:`config.inc.php`. You'll probably need only a few directives to get going; a
505 simple configuration may look like this:
507 .. code-block:: xml+php
509     <?php
510     // use here a value of your choice at least 32 chars long
511     $cfg['blowfish_secret'] = '1{dd0`<Q),5XP_:R9UK%%8\"EEcyH#{o';
513     $i=0;
514     $i++;
515     $cfg['Servers'][$i]['auth_type']     = 'cookie';
516     // if you insist on "root" having no password:
517     // $cfg['Servers'][$i]['AllowNoPassword'] = true; `
518     ?>
520 Or, if you prefer to not be prompted every time you log in:
522 .. code-block:: xml+php
524     <?php
526     $i=0;
527     $i++;
528     $cfg['Servers'][$i]['user']          = 'root';
529     $cfg['Servers'][$i]['password']      = 'cbb74bc'; // use here your password
530     $cfg['Servers'][$i]['auth_type']     = 'config';
531     ?>
533 .. warning::
535     Storing passwords in the configuration is insecure as anybody can then
536     manipulate your database.
538 For a full explanation of possible configuration values, see the
539 :ref:`config` of this document.
541 .. index:: Setup script
543 .. _setup_script:
545 Using Setup script
546 ------------------
548 Instead of manually editing :file:`config.inc.php`, you can use phpMyAdmin's
549 setup feature. The file can be generated using the setup and you can download it
550 for upload to the server.
552 Next, open your browser and visit the location where you installed phpMyAdmin,
553 with the ``/setup`` suffix. The changes are not saved to the server, you need to
554 use the :guilabel:`Download` button to save them to your computer and then upload
555 to the server.
557 Now the file is ready to be used. You can choose to review or edit the
558 file with your favorite editor, if you prefer to set some advanced
559 options which the setup script does not provide.
561 #. If you are using the ``auth_type`` "config", it is suggested that you
562    protect the phpMyAdmin installation directory because using config
563    does not require a user to enter a password to access the phpMyAdmin
564    installation. Use of an alternate authentication method is
565    recommended, for example with HTTP–AUTH in a :term:`.htaccess` file or switch to using
566    ``auth_type`` cookie or http. See the :ref:`faqmultiuser`
567    for additional information, especially :ref:`faq4_4`.
568 #. Open the main phpMyAdmin directory in your browser.
569    phpMyAdmin should now display a welcome screen and your databases, or
570    a login dialog if using :term:`HTTP` or
571    cookie authentication mode.
573 .. _debian-setup:
575 Setup script on Debian, Ubuntu and derivatives
576 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
578 Debian and Ubuntu have changed way how setup is enabled and disabled, in a way
579 that single command has to be executed for either of these.
581 To allow editing configuration invoke:
583 .. code-block:: sh
585    /usr/sbin/pma-configure
587 To block editing configuration invoke:
589 .. code-block:: sh
591     /usr/sbin/pma-secure
593 Setup script on openSUSE
594 ~~~~~~~~~~~~~~~~~~~~~~~~
596 Some openSUSE releases do not include setup script in the package. In case you
597 want to generate configuration on these you can either download original
598 package from <https://www.phpmyadmin.net/> or use setup script on our demo
599 server: <https://demo.phpmyadmin.net/master/setup/>.
601 .. _verify:
603 Verifying phpMyAdmin releases
604 +++++++++++++++++++++++++++++
606 Since July 2015 all phpMyAdmin releases are cryptographically signed by the
607 releasing developer, who through January 2016 was Marc Delisle. His key id is
608 0xFEFC65D181AF644A, his PGP fingerprint is:
610 .. code-block:: console
612     436F F188 4B1A 0C3F DCBF 0D79 FEFC 65D1 81AF 644A
614 and you can get more identification information from <https://keybase.io/lem9>.
616 Beginning in January 2016, the release manager is Isaac Bennetch. His key id is
617 0xCE752F178259BD92, and his PGP fingerprint is:
619 .. code-block:: console
621     3D06 A59E CE73 0EB7 1B51 1C17 CE75 2F17 8259 BD92
623 and you can get more identification information from <https://keybase.io/ibennetch>.
625 Some additional downloads (for example themes) might be signed by Michal Čihař. His key id is
626 0x9C27B31342B7511D, and his PGP fingerprint is:
628 .. code-block:: console
630     63CB 1DF1 EF12 CF2A C0EE 5A32 9C27 B313 42B7 511D
632 and you can get more identification information from <https://keybase.io/nijel>.
634 You should verify that the signature matches the archive you have downloaded.
635 This way you can be sure that you are using the same code that was released.
636 You should also verify the date of the signature to make sure that you
637 downloaded the latest version.
639 Each archive is accompanied with ``.asc`` files which contains the PGP signature
640 for it. Once you have both of them in the same folder, you can verify the signature:
642 .. code-block:: console
644     $ gpg --verify phpMyAdmin-4.5.4.1-all-languages.zip.asc
645     gpg: Signature made Fri 29 Jan 2016 08:59:37 AM EST using RSA key ID 8259BD92
646     gpg: Can't check signature: public key not found
648 As you can see gpg complains that it does not know the public key. At this
649 point you should do one of the following steps:
651 * Download the keyring from `our download server <https://files.phpmyadmin.net/phpmyadmin.keyring>`_, then import it with:
653 .. code-block:: console
655    $ gpg --import phpmyadmin.keyring
657 * Download and import the key from one of the key servers:
659 .. code-block:: console
661     $ gpg --keyserver hkp://pgp.mit.edu --recv-keys 3D06A59ECE730EB71B511C17CE752F178259BD92
662     gpg: requesting key 8259BD92 from hkp server pgp.mit.edu
663     gpg: key 8259BD92: public key "Isaac Bennetch <bennetch@gmail.com>" imported
664     gpg: no ultimately trusted keys found
665     gpg: Total number processed: 1
666     gpg:               imported: 1  (RSA: 1)
668 This will improve the situation a bit - at this point you can verify that the
669 signature from the given key is correct but you still can not trust the name used
670 in the key:
672 .. code-block:: console
674     $ gpg --verify phpMyAdmin-4.5.4.1-all-languages.zip.asc
675     gpg: Signature made Fri 29 Jan 2016 08:59:37 AM EST using RSA key ID 8259BD92
676     gpg: Good signature from "Isaac Bennetch <bennetch@gmail.com>"
677     gpg:                 aka "Isaac Bennetch <isaac@bennetch.org>"
678     gpg: WARNING: This key is not certified with a trusted signature!
679     gpg:          There is no indication that the signature belongs to the owner.
680     Primary key fingerprint: 3D06 A59E CE73 0EB7 1B51  1C17 CE75 2F17 8259 BD92
682 The problem here is that anybody could issue the key with this name.  You need to
683 ensure that the key is actually owned by the mentioned person.  The GNU Privacy
684 Handbook covers this topic in the chapter `Validating other keys on your public
685 keyring`_. The most reliable method is to meet the developer in person and
686 exchange key fingerprints, however you can also rely on the web of trust. This way
687 you can trust the key transitively though signatures of others, who have met
688 the developer in person. For example you can see how `Isaac's key links to
689 Linus's key`_.
691 Once the key is trusted, the warning will not occur:
693 .. code-block:: console
695     $ gpg --verify phpMyAdmin-4.5.4.1-all-languages.zip.asc
696     gpg: Signature made Fri 29 Jan 2016 08:59:37 AM EST using RSA key ID 8259BD92
697     gpg: Good signature from "Isaac Bennetch <bennetch@gmail.com>" [full]
699 Should the signature be invalid (the archive has been changed), you would get a
700 clear error regardless of the fact that the key is trusted or not:
702 .. code-block:: console
704     $ gpg --verify phpMyAdmin-4.5.4.1-all-languages.zip.asc
705     gpg: Signature made Fri 29 Jan 2016 08:59:37 AM EST using RSA key ID 8259BD92
706     gpg: BAD signature from "Isaac Bennetch <bennetch@gmail.com>" [unknown]
708 .. _Validating other keys on your public keyring: https://www.gnupg.org/gph/en/manual.html#AEN335
710 .. _Isaac's key links to Linus's key: https://pgp.cs.uu.nl/paths/79be3e4300411886/to/ce752f178259bd92.html
712 .. index::
713     single: Configuration storage
714     single: phpMyAdmin configuration storage
715     single: pmadb
717 .. _linked-tables:
719 phpMyAdmin configuration storage
720 ++++++++++++++++++++++++++++++++
722 .. versionchanged:: 3.4.0
724    Prior to phpMyAdmin 3.4.0 this was called Linked Tables Infrastructure, but
725    the name was changed due to extended scope of the storage.
727 For a whole set of additional features (:ref:`bookmarks`, comments, :term:`SQL`-history,
728 tracking mechanism, :term:`PDF`-generation, :ref:`transformations`, :ref:`relations`
729 etc.) you need to create a set of special tables.  Those tables can be located
730 in your own database, or in a central database for a multi-user installation
731 (this database would then be accessed by the controluser, so no other user
732 should have rights to it).
734 .. _zeroconf:
736 Zero configuration
737 ------------------
739 In many cases, this database structure can be automatically created and
740 configured. This is called “Zero Configuration” mode and can be particularly
741 useful in shared hosting situations. “Zeroconf” mode is on by default, to
742 disable set :config:option:`$cfg['ZeroConf']` to false.
744 The following three scenarios are covered by the Zero Configuration mode:
746 * When entering a database where the configuration storage tables are not
747   present, phpMyAdmin offers to create them from the Operations tab.
748 * When entering a database where the tables do already exist, the software
749   automatically detects this and begins using them. This is the most common
750   situation; after the tables are initially created automatically they are
751   continually used without disturbing the user; this is also most useful on
752   shared hosting where the user is not able to edit :file:`config.inc.php` and
753   usually the user only has access to one database.
754 * When having access to multiple databases, if the user first enters the
755   database containing the configuration storage tables then switches to
756   another database,
757   phpMyAdmin continues to use the tables from the first database; the user is
758   not prompted to create more tables in the new database.
760 Manual configuration
761 --------------------
763 Please look at your ``./sql/`` directory, where you should find a
764 file called *create\_tables.sql*. (If you are using a Windows server,
765 pay special attention to :ref:`faq1_23`).
767 If you already had this infrastructure and:
769 * upgraded to MySQL 4.1.2 or newer, please use
770   :file:`sql/upgrade_tables_mysql_4_1_2+.sql`.
771 * upgraded to phpMyAdmin 4.3.0 or newer from 2.5.0 or newer (<= 4.2.x),
772   please use :file:`sql/upgrade_column_info_4_3_0+.sql`.
773 * upgraded to phpMyAdmin 4.7.0 or newer from 4.3.0 or newer,
774   please use :file:`sql/upgrade_tables_4_7_0+.sql`.
776 and then create new tables by importing :file:`sql/create_tables.sql`.
778 You can use your phpMyAdmin to create the tables for you. Please be
779 aware that you may need special (administrator) privileges to create
780 the database and tables, and that the script may need some tuning,
781 depending on the database name.
783 After having imported the :file:`sql/create_tables.sql` file, you
784 should specify the table names in your :file:`config.inc.php` file. The
785 directives used for that can be found in the :ref:`config`.
787 You will also need to have a controluser
788 (:config:option:`$cfg['Servers'][$i]['controluser']` and
789 :config:option:`$cfg['Servers'][$i]['controlpass']` settings)
790 with the proper rights to those tables. For example you can create it
791 using following statement:
793 .. code-block:: mysql
795    GRANT SELECT, INSERT, UPDATE, DELETE ON <pma_db>.* TO 'pma'@'localhost'  IDENTIFIED BY 'pmapass';
797 .. _upgrading:
799 Upgrading from an older version
800 +++++++++++++++++++++++++++++++
802 .. warning::
804     **Never** extract the new version over an existing installation of
805     phpMyAdmin, always first remove the old files keeping just the
806     configuration.
808     This way you will not leave old no longer working code in the directory,
809     which can have severe security implications or can cause various breakages.
811 Simply copy :file:`config.inc.php` from your previous installation into
812 the newly unpacked one. Configuration files from old versions may
813 require some tweaking as some options have been changed or removed.
814 For compatibility with PHP 5.3 and later, remove a
815 ``set_magic_quotes_runtime(0);`` statement that you might find near
816 the end of your configuration file.
818 You should **not** copy :file:`libraries/config.default.php` over
819 :file:`config.inc.php` because the default configuration file is version-
820 specific.
822 The complete upgrade can be performed in few simple steps:
824 1. Download the latest phpMyAdmin version from <https://www.phpmyadmin.net/downloads/>.
825 2. Rename existing phpMyAdmin folder (for example to ``phpmyadmin-old``).
826 3. Unpack freshly donwloaded phpMyAdmin to desired location (for example ``phpmyadmin``).
827 4. Copy :file:`config.inc.php`` from old location (``phpmyadmin-old``) to new one (``phpmyadmin``).
828 5. Test that everything works properly.
829 6. Remove backup of previous version (``phpmyadmin-old``).
831 If you have upgraded your MySQL server from a version previous to 4.1.2 to
832 version 5.x or newer and if you use the phpMyAdmin configuration storage, you
833 should run the :term:`SQL` script found in
834 :file:`sql/upgrade_tables_mysql_4_1_2+.sql`.
836 If you have upgraded your phpMyAdmin to 4.3.0 or newer from 2.5.0 or
837 newer (<= 4.2.x) and if you use the phpMyAdmin configuration storage, you
838 should run the :term:`SQL` script found in
839 :file:`sql/upgrade_column_info_4_3_0+.sql`.
841 Do not forget to clear the browser cache and to empty the old session by
842 logging out and logging in again.
844 .. index:: Authentication mode
846 .. _authentication_modes:
848 Using authentication modes
849 ++++++++++++++++++++++++++
851 :term:`HTTP` and cookie authentication modes are recommended in a **multi-user
852 environment** where you want to give users access to their own database and
853 don't want them to play around with others. Nevertheless be aware that MS
854 Internet Explorer seems to be really buggy about cookies, at least till version
855 6. Even in a **single-user environment**, you might prefer to use :term:`HTTP`
856 or cookie mode so that your user/password pair are not in clear in the
857 configuration file.
859 :term:`HTTP` and cookie authentication
860 modes are more secure: the MySQL login information does not need to be
861 set in the phpMyAdmin configuration file (except possibly for the
862 :config:option:`$cfg['Servers'][$i]['controluser']`).
863 However, keep in mind that the password travels in plain text, unless
864 you are using the HTTPS protocol. In cookie mode, the password is
865 stored, encrypted with the AES algorithm, in a temporary cookie.
867 Then each of the *true* users should be granted a set of privileges
868 on a set of particular databases. Normally you shouldn't give global
869 privileges to an ordinary user, unless you understand the impact of those
870 privileges (for example, you are creating a superuser).
871 For example, to grant the user *real_user* with all privileges on
872 the database *user_base*:
874 .. code-block:: mysql
876    GRANT ALL PRIVILEGES ON user_base.* TO 'real_user'@localhost IDENTIFIED BY 'real_password';
878 What the user may now do is controlled entirely by the MySQL user management
879 system. With HTTP or cookie authentication mode, you don't need to fill the
880 user/password fields inside the :config:option:`$cfg['Servers']`.
882 .. seealso::
884     :ref:`faq1_32`,
885     :ref:`faq1_35`,
886     :ref:`faq4_1`,
887     :ref:`faq4_2`,
888     :ref:`faq4_3`
890 .. index:: pair: HTTP; Authentication mode
892 .. _auth_http:
894 HTTP authentication mode
895 ------------------------
897 * Uses :term:`HTTP` Basic authentication
898   method and allows you to log in as any valid MySQL user.
899 * Is supported with most PHP configurations. For :term:`IIS` (:term:`ISAPI`)
900   support using :term:`CGI` PHP see :ref:`faq1_32`, for using with Apache
901   :term:`CGI` see :ref:`faq1_35`.
902 * When PHP is running under Apache's :term:`mod_proxy_fcgi` (e.g. with PHP-FPM),
903   ``Authorization`` headers are not passed to the underlying FCGI application,
904   such that your credentials will not reach the application. In this case, you can
905   add the following configuration directive:
907   .. code-block:: apache
909      SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
911 * See also :ref:`faq4_4` about not using the :term:`.htaccess` mechanism along with
912   ':term:`HTTP`' authentication mode.
914 .. note::
916     There is no way to do proper logout in HTTP authentication, most browsers
917     will remember credentials until there is no different successful
918     authentication. Because of this this method has limitation that you can not
919     login with same user after logout.
921 .. index:: pair: Cookie; Authentication mode
923 .. _cookie:
925 Cookie authentication mode
926 --------------------------
928 * Username and password are stored in cookies during the session and password
929   is deleted when it ends.
930 * With this mode, the user can truly log out of phpMyAdmin and log
931   back in with the same username (this is not possible with :ref:`auth_http`).
932 * If you want to allow users to enter any hostname to connect (rather than only
933   servers that are configured in :file:`config.inc.php`),
934   see the :config:option:`$cfg['AllowArbitraryServer']` directive.
935 * As mentioned in the :ref:`require` section, having the ``openssl`` extension
936   will speed up access considerably, but is not required.
938 .. index:: pair: Signon; Authentication mode
940 .. _auth_signon:
942 Signon authentication mode
943 --------------------------
945 * This mode is a convenient way of using credentials from another
946   application to authenticate to phpMyAdmin to implement single signon
947   solution.
948 * The other application has to store login information into session
949   data (see :config:option:`$cfg['Servers'][$i]['SignonSession']` and
950   :config:option:`$cfg['Servers'][$i]['SignonCookieParams']`) or you
951   need to implement script to return the credentials (see
952   :config:option:`$cfg['Servers'][$i]['SignonScript']`).
953 * When no credentials are available, the user is being redirected to
954   :config:option:`$cfg['Servers'][$i]['SignonURL']`, where you should handle
955   the login process.
957 The very basic example of saving credentials in a session is available as
958 :file:`examples/signon.php`:
960 .. literalinclude:: ../examples/signon.php
961     :language: php
963 Alternatively you can also use this way to integrate with OpenID as shown
964 in :file:`examples/openid.php`:
966 .. literalinclude:: ../examples/openid.php
967     :language: php
969 If you intend to pass the credentials using some other means than, you have to
970 implement wrapper in PHP to get that data and set it to
971 :config:option:`$cfg['Servers'][$i]['SignonScript']`. There is very minimal example
972 in :file:`examples/signon-script.php`:
974 .. literalinclude:: ../examples/signon-script.php
975     :language: php
977 .. seealso::
978     :config:option:`$cfg['Servers'][$i]['auth_type']`,
979     :config:option:`$cfg['Servers'][$i]['SignonSession']`,
980     :config:option:`$cfg['Servers'][$i]['SignonCookieParams']`,
981     :config:option:`$cfg['Servers'][$i]['SignonScript']`,
982     :config:option:`$cfg['Servers'][$i]['SignonURL']`,
983     :ref:`example-signon`
985 .. index:: pair: Config; Authentication mode
987 .. _auth_config:
989 Config authentication mode
990 --------------------------
992 * This mode is sometimes the less secure one because it requires you to fill the
993   :config:option:`$cfg['Servers'][$i]['user']` and
994   :config:option:`$cfg['Servers'][$i]['password']`
995   fields (and as a result, anyone who can read your :file:`config.inc.php`
996   can discover your username and password).
997 * In the :ref:`faqmultiuser` section, there is an entry explaining how
998   to protect your configuration file.
999 * For additional security in this mode, you may wish to consider the
1000   Host authentication :config:option:`$cfg['Servers'][$i]['AllowDeny']['order']`
1001   and :config:option:`$cfg['Servers'][$i]['AllowDeny']['rules']` configuration directives.
1002 * Unlike cookie and http, does not require a user to log in when first
1003   loading the phpMyAdmin site. This is by design but could allow any
1004   user to access your installation. Use of some restriction method is
1005   suggested, perhaps a :term:`.htaccess` file with the HTTP-AUTH directive or disallowing
1006   incoming HTTP requests at one’s router or firewall will suffice (both
1007   of which are beyond the scope of this manual but easily searchable
1008   with Google).
1010 .. _securing:
1012 Securing your phpMyAdmin installation
1013 +++++++++++++++++++++++++++++++++++++
1015 The phpMyAdmin team tries hard to make the application secure, however there
1016 are always ways to make your installation more secure:
1018 * Follow our `Security announcements <https://www.phpmyadmin.net/security/>`_ and upgrade
1019   phpMyAdmin whenever new vulnerability is published.
1020 * Serve phpMyAdmin on HTTPS only. Preferably, you should use HSTS as well, so that
1021   you're protected from protocol downgrade attacks.
1022 * Ensure your PHP setup follows recommendations for production sites, for example
1023   `display_errors <https://secure.php.net/manual/en/errorfunc.configuration.php#ini.display-errors>`_
1024   should be disabled.
1025 * Remove the ``test`` directory from phpMyAdmin, unless you are developing and need test suite.
1026 * Remove the ``setup`` directory from phpMyAdmin, you will probably not
1027   use it after the initial setup.
1028 * Properly choose an authentication method - :ref:`cookie`
1029   is probably the best choice for shared hosting.
1030 * Deny access to auxiliary files in :file:`./libraries/` or
1031   :file:`./templates/` subfolders in your webserver configuration.
1032   Such configuration prevents from possible path exposure and cross side
1033   scripting vulnerabilities that might happen to be found in that code. For the
1034   Apache webserver, this is often accomplished with a :term:`.htaccess` file in
1035   those directories.
1036 * Deny access to temporary files, see :config:option:`$cfg['TempDir']` (if that
1037   is placed inside your web root, see also :ref:`web-dirs`.
1038 * It is generally a good idea to protect a public phpMyAdmin installation
1039   against access by robots as they usually can not do anything good there. You
1040   can do this using ``robots.txt`` file in root of your webserver or limit
1041   access by web server configuration, see :ref:`faq1_42`.
1042 * In case you don't want all MySQL users to be able to access
1043   phpMyAdmin, you can use :config:option:`$cfg['Servers'][$i]['AllowDeny']['rules']` to limit them
1044   or :config:option:`$cfg['Servers'][$i]['AllowRoot']` to deny root user access.
1045 * Enable :ref:`2fa` for your account.
1046 * Consider hiding phpMyAdmin behind an authentication proxy, so that
1047   users need to authenticate prior to providing MySQL credentials
1048   to phpMyAdmin. You can achieve this by configuring your web server to request
1049   HTTP authentication. For example in Apache this can be done with:
1051   .. code-block:: apache
1053      AuthType Basic
1054      AuthName "Restricted Access"
1055      AuthUserFile /usr/share/phpmyadmin/passwd
1056      Require valid-user
1058   Once you have changed the configuration, you need to create a list of users which
1059   can authenticate. This can be done using the :program:`htpasswd` utility:
1061   .. code-block:: sh
1063      htpasswd -c /usr/share/phpmyadmin/passwd username
1065 * If you are afraid of automated attacks, enabling Captcha by
1066   :config:option:`$cfg['CaptchaLoginPublicKey']` and
1067   :config:option:`$cfg['CaptchaLoginPrivateKey']` might be an option.
1068 * Failed login attemps are logged to syslog (if available, see
1069   :config:option:`$cfg['AuthLog']`). This can allow using a tool such as
1070   fail2ban to block brute-force attempts. Note that the log file used by syslog
1071   is not the same as the Apache error or access log files.
1072 * In case you're running phpMyAdmin together with other PHP applications, it is
1073   generally advised to use separate session storage for phpMyAdmin to avoid
1074   possible session based attacks against it. You can use
1075   :config:option:`$cfg['SessionSavePath']` to achieve this.
1077 .. _ssl:
1079 Using SSL for connection to database server
1080 +++++++++++++++++++++++++++++++++++++++++++
1082 It is recommended to use SSL when connecting to remote database server. There
1083 are several configuration options involved in the SSL setup:
1085 :config:option:`$cfg['Servers'][$i]['ssl']`
1086     Defines whether to use SSL at all. If you enable only this, the connection
1087     will be encrypted, but there is not authentication of the connection - you
1088     can not verify that you are talking to the right server.
1089 :config:option:`$cfg['Servers'][$i]['ssl_key']` and :config:option:`$cfg['Servers'][$i]['ssl_cert']`
1090     This is used for authentication of client to the server.
1091 :config:option:`$cfg['Servers'][$i]['ssl_ca']` and :config:option:`$cfg['Servers'][$i]['ssl_ca_path']`
1092     The certificate authorities you trust for server certificates.
1093     This is used to ensure that you are talking to a trusted server.
1094 :config:option:`$cfg['Servers'][$i]['ssl_verify']`
1095     This configuration disables server certificate verification. Use with
1096     caution.
1098 .. seealso::
1100     :ref:`example-google-ssl`,
1101     :config:option:`$cfg['Servers'][$i]['ssl']`,
1102     :config:option:`$cfg['Servers'][$i]['ssl_key']`,
1103     :config:option:`$cfg['Servers'][$i]['ssl_cert']`,
1104     :config:option:`$cfg['Servers'][$i]['ssl_ca']`,
1105     :config:option:`$cfg['Servers'][$i]['ssl_ca_path']`,
1106     :config:option:`$cfg['Servers'][$i]['ssl_ciphers']`,
1107     :config:option:`$cfg['Servers'][$i]['ssl_verify']`
1109 Known issues
1110 ++++++++++++
1112 Users with column-specific privileges are unable to "Browse"
1113 ------------------------------------------------------------
1115 If a user has only column-specific privileges on some (but not all) columns in a table, "Browse"
1116 will fail with an error message.
1118 As a workaround, a bookmarked query with the same name as the table can be created, this will
1119 run when using the "Browse" link instead. `Issue 11922 <https://github.com/phpmyadmin/phpmyadmin/issues/11922>`_.
1121 Trouble logging back in after logging out using 'http' authentication
1122 ----------------------------------------------------------------------
1124 When using the 'http' ``auth_type``, it can be impossible to log back in (when the logout comes
1125 manually or after a period of inactivity). `Issue 11898 <https://github.com/phpmyadmin/phpmyadmin/issues/11898>`_.
1127 .. _Composer tool: https://getcomposer.org/
1128 .. _Packagist: https://packagist.org/
1129 .. _Docker image: https://hub.docker.com/r/phpmyadmin/phpmyadmin/