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.
14 phpMyAdmin is included in most Linux distributions. It is recommended to use
15 distribution packages when possible - they usually provide integration to your
16 distribution and you will automatically get security updates from your distribution.
23 Most Debian and Ubuntu versions include a phpMyAdmin package, but be aware that
24 the configuration file is maintained in ``/etc/phpmyadmin`` and may differ in
25 some ways from the official phpMyAdmin documentation. Specifically, it does:
27 * Configuration of a web server (works for Apache and lighttpd).
28 * Creating of :ref:`linked-tables` using dbconfig-common.
29 * Securing setup script, see :ref:`debian-setup`.
31 More specific details about installing Debian or Ubuntu packages are available
32 `in our wiki <https://github.com/phpmyadmin/phpmyadmin/wiki/DebianUbuntu>`_.
36 More information can be found in `README.Debian <https://salsa.debian.org/phpmyadmin-team/phpmyadmin/blob/debian/latest/debian/README.Debian>`_
37 (it is installed as :file:`/usr/share/doc/phpmyadmin/README.Debian` with the package).
42 OpenSUSE already comes with phpMyAdmin package, just install packages from
43 the `openSUSE Build Service <https://software.opensuse.org/package/phpMyAdmin>`_.
48 Gentoo ships the phpMyAdmin package, both in a near-stock configuration as well
49 as in a ``webapp-config`` configuration. Use ``emerge dev-db/phpmyadmin`` to
55 Mandriva ships the phpMyAdmin package in their ``contrib`` branch and can be
56 installed via the usual Control Center.
61 Fedora ships the phpMyAdmin package, but be aware that the configuration file
62 is maintained in ``/etc/phpMyAdmin/`` and may differ in some ways from the
63 official phpMyAdmin documentation.
65 Red Hat Enterprise Linux
66 ------------------------
68 Red Hat Enterprise Linux itself and thus derivatives like CentOS don't
69 ship phpMyAdmin, but the Fedora-driven repository
70 `Extra Packages for Enterprise Linux (EPEL) <https://fedoraproject.org/wiki/EPEL>`_
72 `enabled <https://fedoraproject.org/wiki/EPEL/FAQ#howtouse>`_.
73 But be aware that the configuration file is maintained in
74 ``/etc/phpMyAdmin/`` and may differ in some ways from the
75 official phpMyAdmin documentation.
80 The easiest way to get phpMyAdmin on Windows is using third party products
81 which include phpMyAdmin together with a database and web server such as
82 `XAMPP <https://www.apachefriends.org/index.html>`_.
84 You can find more of such options at `Wikipedia <https://en.wikipedia.org/wiki/List_of_AMP_packages>`_.
89 In order to install from Git, you'll need a few supporting applications:
91 * `Git <https://git-scm.com/downloads>`_ to download the source, or you can download the most recent source directly from `Github <https://codeload.github.com/phpmyadmin/phpmyadmin/zip/QA_5_2>`_
92 * `Composer <https://getcomposer.org/download/>`__
93 * `Node.js <https://nodejs.org/en/download/>`_ (version 10 or higher)
94 * `Yarn <https://classic.yarnpkg.com/en/docs/install>`_
96 You can clone current phpMyAdmin source from
97 ``https://github.com/phpmyadmin/phpmyadmin.git``:
101 git clone https://github.com/phpmyadmin/phpmyadmin.git
103 Additionally you need to install dependencies using `Composer <https://getcomposer.org>`__:
109 If you do not intend to develop, you can skip the installation of developer tools
114 composer update --no-dev
116 Finally, you'll need to use `Yarn`_ to install some JavaScript dependencies:
120 yarn install --production
124 Installing using Composer
125 +++++++++++++++++++++++++
127 You can install phpMyAdmin using the `Composer tool`_, since 4.7.0 the releases
128 are automatically mirrored to the default `Packagist`_ repository.
132 The content of the Composer repository is automatically generated
133 separately from the releases, so the content doesn't have to be
134 100% same as when you download the tarball. There should be no
135 functional differences though.
137 To install phpMyAdmin simply run:
141 composer create-project phpmyadmin/phpmyadmin
143 Alternatively you can use our own composer repository, which contains
144 the release tarballs and is available at
145 <https://www.phpmyadmin.net/packages.json>:
149 composer create-project phpmyadmin/phpmyadmin --repository-url=https://www.phpmyadmin.net/packages.json --no-dev
153 Installing using Docker
154 +++++++++++++++++++++++
156 phpMyAdmin comes with a `Docker official image`_, which you can easily deploy. You can
161 docker pull phpmyadmin
163 The phpMyAdmin server will listen on port 80. It supports several ways of
164 configuring the link to the database server, either by Docker's link feature
165 by linking your database container to ``db`` for phpMyAdmin (by specifying
166 ``--link your_db_host:db``) or by environment variables (in this case it's up
167 to you to set up networking in Docker to allow the phpMyAdmin container to access
168 the database container over the network).
172 Docker environment variables
173 ----------------------------
175 You can configure several phpMyAdmin features using environment variables:
177 .. envvar:: PMA_ARBITRARY
179 Allows you to enter a database server hostname on login form.
181 .. seealso:: :config:option:`$cfg['AllowArbitraryServer']`
185 Hostname or IP address of the database server to use.
187 .. seealso:: :config:option:`$cfg['Servers'][$i]['host']`
189 .. envvar:: PMA_HOSTS
191 Comma-separated hostnames or IP addresses of the database servers to use.
193 .. note:: Used only if :envvar:`PMA_HOST` is empty.
195 .. envvar:: PMA_VERBOSE
197 Verbose name of the database server.
199 .. seealso:: :config:option:`$cfg['Servers'][$i]['verbose']`
201 .. envvar:: PMA_VERBOSES
203 Comma-separated verbose name of the database servers.
205 .. note:: Used only if :envvar:`PMA_VERBOSE` is empty.
209 User name to use for :ref:`auth_config`.
211 .. envvar:: PMA_PASSWORD
213 Password to use for :ref:`auth_config`.
217 Port of the database server to use.
219 .. envvar:: PMA_PORTS
221 Comma-separated ports of the database server to use.
223 .. note:: Used only if :envvar:`PMA_PORT` is empty.
225 .. envvar:: PMA_ABSOLUTE_URI
227 The fully-qualified path (``https://pma.example.net/``) where the reverse
228 proxy makes phpMyAdmin available.
230 .. seealso:: :config:option:`$cfg['PmaAbsoluteUri']`
232 .. envvar:: PMA_QUERYHISTORYDB
234 When set to `true`, enables storing SQL history to :config:option:`$cfg['Servers'][$i]['pmadb']`.
235 When `false`, history is stored in the browser and is cleared when logging out.
237 .. seealso:: :config:option:`$cfg['Servers'][$i]['history']`
238 .. seealso:: :config:option:`$cfg['QueryHistoryDB']`
240 .. envvar:: PMA_QUERYHISTORYMAX
242 When set to an integer, controls the number of history items.
244 .. seealso:: :config:option:`$cfg['QueryHistoryMax']`
246 .. envvar:: PMA_CONTROLHOST
248 When set, this points to an alternate database host used for storing the ":ref:`linked-tables`" database.
250 .. seealso:: :config:option:`$cfg['Servers'][$i]['controlhost']`
252 .. envvar:: PMA_CONTROLUSER
254 Defines the username for phpMyAdmin to use for the ":ref:`linked-tables`" database.
256 .. seealso:: :config:option:`$cfg['Servers'][$i]['controluser']`
258 .. envvar:: PMA_CONTROLPASS
260 Defines the password for phpMyAdmin to use for the ":ref:`linked-tables`" database.
262 .. seealso:: :config:option:`$cfg['Servers'][$i]['controlpass']`
264 .. envvar:: PMA_CONTROLPORT
266 When set, will override the default port (`3306`) for connecting to the control host.
268 .. seealso:: :config:option:`$cfg['Servers'][$i]['controlport']`
270 .. envvar:: PMA_PMADB
272 When set, define the name of the database to be used for the ":ref:`linked-tables`" database.
273 When not set, the advanced features are not enabled by default: they can still potentially be enabled by the user when logging in with the :ref:`zeroconf` feature.
275 .. note:: Suggested values: `phpmyadmin` or `pmadb`
277 .. seealso:: :config:option:`$cfg['Servers'][$i]['pmadb']`
279 .. envvar:: HIDE_PHP_VERSION
281 If defined, this option will hide the PHP version (`expose_php = Off`).
282 Set to any value (such as `HIDE_PHP_VERSION=true`).
284 .. envvar:: UPLOAD_LIMIT
286 If set, this option will override the default value for apache and php-fpm (this will change ``upload_max_filesize`` and ``post_max_size`` values).
288 .. note:: Format as `[0-9+](K,M,G)` default value is `2048K`
290 .. envvar:: MEMORY_LIMIT
292 If set, this option will override the phpMyAdmin memory limit :config:option:`$cfg['MemoryLimit']` and PHP's `memory_limit`.
294 .. note:: Format as `[0-9+](K,M,G)` where `K` is for Kilobytes, `M` for Megabytes, `G` for Gigabytes and `1K` = 1024 bytes. Default value is `512M`.
296 .. envvar:: MAX_EXECUTION_TIME
298 If set, this option will override the maximum execution time in seconds for phpMyAdmin :config:option:`$cfg['ExecTimeLimit']` and PHP's `max_execution_time`.
300 .. note:: Format as `[0-9+]`. Default value is `600`.
302 .. envvar:: PMA_CONFIG_BASE64
304 If set, this option will override the default `config.inc.php` with the base64 decoded contents of the variable.
306 .. envvar:: PMA_USER_CONFIG_BASE64
308 If set, this option will override the default `config.user.inc.php` with the base64 decoded contents of the variable.
311 By default, :ref:`cookie` is used, but if :envvar:`PMA_USER` and
312 :envvar:`PMA_PASSWORD` are set, it is switched to :ref:`auth_config`.
316 The credentials you need to log in are stored in the MySQL server, in case
317 of Docker image, there are various ways to set it (for example
318 :samp:`MYSQL_ROOT_PASSWORD` when starting the MySQL container). Please check
319 documentation for `MariaDB container <https://hub.docker.com/_/mariadb>`_
320 or `MySQL container <https://hub.docker.com/_/mysql>`_.
324 Customizing configuration
325 -------------------------
327 Additionally configuration can be tweaked by :file:`/etc/phpmyadmin/config.user.inc.php`. If
328 this file exists, it will be loaded after configuration is generated from above
329 environment variables, so you can override any configuration variable. This
330 configuration can be added as a volume when invoking docker using
331 `-v /some/local/directory/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php` parameters.
333 Note that the supplied configuration file is applied after :ref:`docker-vars`,
334 but you can override any of the values.
336 For example to change the default behavior of CSV export you can use the following
342 $cfg['Export']['csv_columns'] = true;
344 You can also use it to define server configuration instead of using the
345 environment variables listed in :ref:`docker-vars`:
350 /* Override Servers array */
353 'auth_type' => 'cookie',
356 'verbose' => 'Verbose name 1',
359 'auth_type' => 'cookie',
362 'verbose' => 'Verbose name 2',
368 See :ref:`config` for detailed description of configuration options.
373 You can use the following volumes to customize image behavior:
375 :file:`/etc/phpmyadmin/config.user.inc.php`
377 Can be used for additional settings, see the previous chapter for more details.
381 Directory where PHP sessions are stored. You might want to share this
382 for example when using :ref:`auth_signon`.
386 Directory where phpMyAdmin looks for themes. By default only those shipped
387 with phpMyAdmin are included, but you can include additional phpMyAdmin
388 themes (see :ref:`themes`) by using Docker volumes.
393 To connect phpMyAdmin to a given server use:
397 docker run --name phpmyadmin -d -e PMA_HOST=dbhost -p 8080:80 phpmyadmin:latest
399 To connect phpMyAdmin to more servers use:
403 docker run --name phpmyadmin -d -e PMA_HOSTS=dbhost1,dbhost2,dbhost3 -p 8080:80 phpmyadmin:latest
405 To use arbitrary server option:
409 docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 -e PMA_ARBITRARY=1 phpmyadmin:latest
411 You can also link the database container using Docker:
415 docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 phpmyadmin:latest
417 Running with additional configuration:
421 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:latest
423 Running with additional themes:
427 docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 -v /some/local/directory/custom/phpmyadmin/themeName/:/var/www/html/themes/themeName/ phpmyadmin:latest
432 Alternatively, you can also use docker-compose with the docker-compose.yml from
433 <https://github.com/phpmyadmin/docker>. This will run phpMyAdmin with an
434 arbitrary server - allowing you to specify MySQL/MariaDB server on the login page.
440 Customizing configuration file using docker-compose
441 ---------------------------------------------------
443 You can use an external file to customize phpMyAdmin configuration and pass it
444 using the volumes directive:
449 image: phpmyadmin:latest
450 container_name: phpmyadmin
458 - ~/docker/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
459 - /custom/phpmyadmin/theme/:/www/themes/theme/
461 .. seealso:: :ref:`docker-custom`
463 Running behind haproxy in a subdirectory
464 ----------------------------------------
466 When you want to expose phpMyAdmin running in a Docker container in a
467 subdirectory, you need to rewrite the request path in the server proxying the
470 For example, using haproxy it can be done as:
477 option http-server-close
479 ### NETWORK restriction
480 acl LOCALNET src 10.0.0.0/8 192.168.0.0/16 172.16.0.0/12
483 acl phpmyadmin path_dir /phpmyadmin
484 use_backend phpmyadmin if phpmyadmin LOCALNET
489 reqirep ^(GET|POST|HEAD)\ /phpmyadmin/(.*) \1\ /\2
491 # phpMyAdmin container IP
492 server localhost 172.30.21.21:80
494 When using traefik, something like following should work:
498 defaultEntryPoints = ["http"]
502 [entryPoints.http.redirect]
503 regex = "(http:\\/\\/[^\\/]+\\/([^\\?\\.]+)[^\\/])$"
508 [backends.myadmin.servers.myadmin]
509 url="http://internal.address.to.pma"
514 passHostHeader = true
515 [frontends.myadmin.routes.default]
516 rule="PathPrefixStrip:/phpmyadmin/;AddPrefix:/"
518 You then should specify :envvar:`PMA_ABSOLUTE_URI` in the docker-compose
528 image: phpmyadmin:latest
529 container_name: phpmyadmin
531 domainname: example.com
535 - PMA_HOSTS=172.26.36.7,172.26.36.8,172.26.36.9,172.26.36.10
536 - PMA_VERBOSES=production-db1,production-db2,dev-db1,dev-db2
539 - PMA_ABSOLUTE_URI=http://example.com/phpmyadmin/
544 One of our users has created a helpful guide for installing phpMyAdmin on the
545 `IBM Cloud platform <https://github.com/KissConsult/phpmyadmin_tutorial#readme>`_.
552 #. Choose an appropriate distribution kit from the phpmyadmin.net
553 Downloads page. Some kits contain only the English messages, others
554 contain all languages. We'll assume you chose a kit whose name
555 looks like ``phpMyAdmin-x.x.x -all-languages.tar.gz``.
556 #. Ensure you have downloaded a genuine archive, see :ref:`verify`.
557 #. Untar or unzip the distribution (be sure to unzip the subdirectories):
558 ``tar -xzvf phpMyAdmin_x.x.x-all-languages.tar.gz`` in your
559 webserver's document root. If you don't have direct access to your
560 document root, put the files in a directory on your local machine,
561 and, after step 4, transfer the directory on your web server using,
563 #. Ensure that all the scripts have the appropriate owner (if PHP is
564 running in safe mode, having some scripts with an owner different from
565 the owner of other scripts will be a problem). See :ref:`faq4_2` and
566 :ref:`faq1_26` for suggestions.
567 #. Now you must configure your installation. There are two methods that
568 can be used. Traditionally, users have hand-edited a copy of
569 :file:`config.inc.php`, but now a wizard-style setup script is provided
570 for those who prefer a graphical installation. Creating a
571 :file:`config.inc.php` is still a quick way to get started and needed for
572 some advanced features.
574 Manually creating the file
575 --------------------------
577 To manually create the file, simply use your text editor to create the
578 file :file:`config.inc.php` (you can copy :file:`config.sample.inc.php` to get
579 a minimal configuration file) in the main (top-level) phpMyAdmin
580 directory (the one that contains :file:`index.php`). phpMyAdmin first
581 loads the default configuration values and then overrides those values
582 with anything found in :file:`config.inc.php`. If the default value is
583 okay for a particular setting, there is no need to include it in
584 :file:`config.inc.php`. You'll probably need only a few directives to get going; a
585 simple configuration may look like this:
587 .. code-block:: xml+php
590 // The string is a hexadecimal representation of a 32-bytes long string of random bytes.
591 $cfg['blowfish_secret'] = sodium_hex2bin('f16ce59f45714194371b48fe362072dc3b019da7861558cd4ad29e4d6fb13851');
595 $cfg['Servers'][$i]['auth_type'] = 'cookie';
596 // if you insist on "root" having no password:
597 // $cfg['Servers'][$i]['AllowNoPassword'] = true;
599 Or, if you prefer to not be prompted every time you log in:
601 .. code-block:: xml+php
607 $cfg['Servers'][$i]['user'] = 'root';
608 $cfg['Servers'][$i]['password'] = 'changeme'; // use here your password
609 $cfg['Servers'][$i]['auth_type'] = 'config';
613 Storing passwords in the configuration is insecure as anybody can then
614 manipulate your database.
616 For a full explanation of possible configuration values, see the
617 :ref:`config` of this document.
619 .. index:: Setup script
623 Using the Setup script
624 ----------------------
626 Instead of manually editing :file:`config.inc.php`, you can use phpMyAdmin's
627 setup feature. The file can be generated using the setup and you can download it
628 for upload to the server.
630 Next, open your browser and visit the location where you installed phpMyAdmin,
631 with the ``/setup`` suffix. The changes are not saved to the server, you need to
632 use the :guilabel:`Download` button to save them to your computer and then upload
635 Now the file is ready to be used. You can choose to review or edit the
636 file with your favorite editor, if you prefer to set some advanced
637 options that the setup script does not provide.
639 #. If you are using the ``auth_type`` "config", it is suggested that you
640 protect the phpMyAdmin installation directory because using config
641 does not require a user to enter a password to access the phpMyAdmin
642 installation. Use of an alternate authentication method is
643 recommended, for example with HTTP–AUTH in a :term:`.htaccess` file or switch to using
644 ``auth_type`` cookie or http. See the :ref:`faqmultiuser`
645 for additional information, especially :ref:`faq4_4`.
646 #. Open the main phpMyAdmin directory in your browser.
647 phpMyAdmin should now display a welcome screen and your databases, or
648 a login dialog if using :term:`HTTP` or
649 cookie authentication mode.
653 Setup script on Debian, Ubuntu and derivatives
654 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
656 Debian and Ubuntu have changed the way in which the setup script is enabled and disabled, in a way
657 that single command has to be executed for either of these.
659 To allow editing configuration invoke:
663 /usr/sbin/pma-configure
665 To block editing configuration invoke:
671 Setup script on openSUSE
672 ~~~~~~~~~~~~~~~~~~~~~~~~
674 Some openSUSE releases do not include setup script in the package. In case you
675 want to generate configuration on these you can either download original
676 package from <https://www.phpmyadmin.net/> or use setup script on our demo
677 server: <https://demo.phpmyadmin.net/master/setup/>.
681 Verifying phpMyAdmin releases
682 +++++++++++++++++++++++++++++
684 Since July 2015 all phpMyAdmin releases are cryptographically signed by the
685 releasing developer, who through January 2016 was Marc Delisle. His key id is
686 0xFEFC65D181AF644A, his PGP fingerprint is:
688 .. code-block:: console
690 436F F188 4B1A 0C3F DCBF 0D79 FEFC 65D1 81AF 644A
692 and you can get more identification information from <https://keybase.io/lem9>.
694 Beginning in January 2016, the release manager is Isaac Bennetch. His key id is
695 0xCE752F178259BD92, and his PGP fingerprint is:
697 .. code-block:: console
699 3D06 A59E CE73 0EB7 1B51 1C17 CE75 2F17 8259 BD92
701 and you can get more identification information from <https://keybase.io/ibennetch>.
703 Some additional downloads (for example themes) might be signed by Michal Čihař. His key id is
704 0x9C27B31342B7511D, and his PGP fingerprint is:
706 .. code-block:: console
708 63CB 1DF1 EF12 CF2A C0EE 5A32 9C27 B313 42B7 511D
710 and you can get more identification information from <https://keybase.io/nijel>.
712 You should verify that the signature matches the archive you have downloaded.
713 This way you can be sure that you are using the same code that was released.
714 You should also verify the date of the signature to make sure that you
715 downloaded the latest version.
717 Each archive is accompanied by ``.asc`` files which contain the PGP signature
718 for it. Once you have both of them in the same folder, you can verify the signature:
720 .. code-block:: console
722 $ gpg --verify phpMyAdmin-4.5.4.1-all-languages.zip.asc
723 gpg: Signature made Fri 29 Jan 2016 08:59:37 AM EST using RSA key ID 8259BD92
724 gpg: Can't check signature: public key not found
726 As you can see gpg complains that it does not know the public key. At this
727 point, you should do one of the following steps:
729 * Download the keyring from `our download server <https://files.phpmyadmin.net/phpmyadmin.keyring>`_, then import it with:
731 .. code-block:: console
733 $ gpg --import phpmyadmin.keyring
735 * Download and import the key from one of the key servers:
737 .. code-block:: console
739 $ gpg --keyserver hkp://pgp.mit.edu --recv-keys 3D06A59ECE730EB71B511C17CE752F178259BD92
740 gpg: requesting key 8259BD92 from hkp server pgp.mit.edu
741 gpg: key 8259BD92: public key "Isaac Bennetch <bennetch@gmail.com>" imported
742 gpg: no ultimately trusted keys found
743 gpg: Total number processed: 1
744 gpg: imported: 1 (RSA: 1)
746 This will improve the situation a bit - at this point, you can verify that the
747 signature from the given key is correct but you still can not trust the name used
750 .. code-block:: console
752 $ gpg --verify phpMyAdmin-4.5.4.1-all-languages.zip.asc
753 gpg: Signature made Fri 29 Jan 2016 08:59:37 AM EST using RSA key ID 8259BD92
754 gpg: Good signature from "Isaac Bennetch <bennetch@gmail.com>"
755 gpg: aka "Isaac Bennetch <isaac@bennetch.org>"
756 gpg: WARNING: This key is not certified with a trusted signature!
757 gpg: There is no indication that the signature belongs to the owner.
758 Primary key fingerprint: 3D06 A59E CE73 0EB7 1B51 1C17 CE75 2F17 8259 BD92
760 The problem here is that anybody could issue the key with this name. You need to
761 ensure that the key is actually owned by the mentioned person. The GNU Privacy
762 Handbook covers this topic in the chapter `Validating other keys on your public
763 keyring`_. The most reliable method is to meet the developer in person and
764 exchange key fingerprints, however, you can also rely on the web of trust. This way
765 you can trust the key transitively though signatures of others, who have met
766 the developer in person.
768 Once the key is trusted, the warning will not occur:
770 .. code-block:: console
772 $ gpg --verify phpMyAdmin-4.5.4.1-all-languages.zip.asc
773 gpg: Signature made Fri 29 Jan 2016 08:59:37 AM EST using RSA key ID 8259BD92
774 gpg: Good signature from "Isaac Bennetch <bennetch@gmail.com>" [full]
776 Should the signature be invalid (the archive has been changed), you would get a
777 clear error regardless of the fact that the key is trusted or not:
779 .. code-block:: console
781 $ gpg --verify phpMyAdmin-4.5.4.1-all-languages.zip.asc
782 gpg: Signature made Fri 29 Jan 2016 08:59:37 AM EST using RSA key ID 8259BD92
783 gpg: BAD signature from "Isaac Bennetch <bennetch@gmail.com>" [unknown]
785 .. _Validating other keys on your public keyring: https://www.gnupg.org/gph/en/manual.html#AEN335
788 single: Configuration storage
789 single: phpMyAdmin configuration storage
794 phpMyAdmin configuration storage
795 ++++++++++++++++++++++++++++++++
797 .. versionchanged:: 3.4.0
799 Prior to phpMyAdmin 3.4.0 this was called Linked Tables Infrastructure, but
800 the name was changed due to the extended scope of the storage.
802 For a whole set of additional features (:ref:`bookmarks`, comments, :term:`SQL`-history,
803 tracking mechanism, :term:`PDF`-generation, :ref:`transformations`, :ref:`relations`
804 etc.) you need to create a set of special tables. Those tables can be located
805 in your own database, or in a central database for a multi-user installation
806 (this database would then be accessed by the controluser, so no other user
807 should have rights to it).
814 In many cases, this database structure can be automatically created and
815 configured. This is called “Zero Configuration” mode and can be particularly
816 useful in shared hosting situations. “Zeroconf” mode is on by default, to
817 disable set :config:option:`$cfg['ZeroConf']` to false.
819 The following three scenarios are covered by the Zero Configuration mode:
821 * When entering a database where the configuration storage tables are not
822 present, phpMyAdmin offers to create them from the Operations tab.
823 * When entering a database where the tables do already exist, the software
824 automatically detects this and begins using them. This is the most common
825 situation; after the tables are initially created automatically they are
826 continually used without disturbing the user; this is also most useful on
827 shared hosting where the user is not able to edit :file:`config.inc.php` and
828 usually the user only has access to one database.
829 * When having access to multiple databases, if the user first enters the
830 database containing the configuration storage tables then switches to
832 phpMyAdmin continues to use the tables from the first database; the user is
833 not prompted to create more tables in the new database.
838 Please look at your ``./sql/`` directory, where you should find a
839 file called *create\_tables.sql*. (If you are using a Windows server,
840 pay special attention to :ref:`faq1_23`).
842 If you already had this infrastructure and:
844 * upgraded to MySQL 4.1.2 or newer, please use
845 :file:`sql/upgrade_tables_mysql_4_1_2+.sql`.
846 * upgraded to phpMyAdmin 4.3.0 or newer from 2.5.0 or newer (<= 4.2.x),
847 please use :file:`sql/upgrade_column_info_4_3_0+.sql`.
848 * upgraded to phpMyAdmin 4.7.0 or newer from 4.3.0 or newer,
849 please use :file:`sql/upgrade_tables_4_7_0+.sql`.
851 and then create new tables by importing :file:`sql/create_tables.sql`.
853 You can use your phpMyAdmin to create the tables for you. Please be
854 aware that you may need special (administrator) privileges to create
855 the database and tables, and that the script may need some tuning,
856 depending on the database name.
858 After having imported the :file:`sql/create_tables.sql` file, you
859 should specify the table names in your :file:`config.inc.php` file. The
860 directives used for that can be found in the :ref:`config`.
862 You will also need to have a controluser
863 (:config:option:`$cfg['Servers'][$i]['controluser']` and
864 :config:option:`$cfg['Servers'][$i]['controlpass']` settings)
865 with the proper rights to those tables. For example you can create it
866 using following statement:
868 And for any MariaDB version:
870 .. code-block:: mysql
872 CREATE USER 'pma'@'localhost' IDENTIFIED VIA mysql_native_password USING 'pmapass';
873 GRANT SELECT, INSERT, UPDATE, DELETE ON `<pma_db>`.* TO 'pma'@'localhost';
875 For MySQL 8.0 and newer:
877 .. code-block:: mysql
879 CREATE USER 'pma'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'pmapass';
880 GRANT SELECT, INSERT, UPDATE, DELETE ON <pma_db>.* TO 'pma'@'localhost';
882 For MySQL older than 8.0:
884 .. code-block:: mysql
886 CREATE USER 'pma'@'localhost' IDENTIFIED WITH mysql_native_password AS 'pmapass';
887 GRANT SELECT, INSERT, UPDATE, DELETE ON <pma_db>.* TO 'pma'@'localhost';
889 Note that MySQL installations with PHP older than 7.4 and MySQL newer than 8.0 may require
890 using the mysql_native_password authentication as a workaround, see
891 :ref:`faq1_45` for details.
895 Upgrading from an older version
896 +++++++++++++++++++++++++++++++
900 **Never** extract the new version over an existing installation of
901 phpMyAdmin, always first remove the old files keeping just the
904 This way, you will not leave any old or outdated files in the directory,
905 which can have severe security implications or can cause various breakages.
907 Simply copy :file:`config.inc.php` from your previous installation into
908 the newly unpacked one. Configuration files from old versions may
909 require some tweaking as some options have been changed or removed.
910 For compatibility with PHP 5.3 and later, remove a
911 ``set_magic_quotes_runtime(0);`` statement that you might find near
912 the end of your configuration file.
914 The complete upgrade can be performed in a few simple steps:
916 1. Download the latest phpMyAdmin version from <https://www.phpmyadmin.net/downloads/>.
917 2. Rename existing phpMyAdmin folder (for example to ``phpmyadmin-old``).
918 3. Unpack freshly downloaded phpMyAdmin to the desired location (for example ``phpmyadmin``).
919 4. Copy :file:`config.inc.php`` from old location (``phpmyadmin-old``) to the new one (``phpmyadmin``).
920 5. Test that everything works properly.
921 6. Remove backup of a previous version (``phpmyadmin-old``).
923 If you have upgraded your MySQL server from a version previous to 4.1.2 to
924 version 5.x or newer and if you use the phpMyAdmin configuration storage, you
925 should run the :term:`SQL` script found in
926 :file:`sql/upgrade_tables_mysql_4_1_2+.sql`.
928 If you have upgraded your phpMyAdmin to 4.3.0 or newer from 2.5.0 or
929 newer (<= 4.2.x) and if you use the phpMyAdmin configuration storage, you
930 should run the :term:`SQL` script found in
931 :file:`sql/upgrade_column_info_4_3_0+.sql`.
933 Do not forget to clear the browser cache and to empty the old session by
934 logging out and logging in again.
936 .. index:: Authentication mode
938 .. _authentication_modes:
940 Using authentication modes
941 ++++++++++++++++++++++++++
943 :term:`HTTP` and cookie authentication modes are recommended in a **multi-user
944 environment** where you want to give users access to their own database and
945 don't want them to play around with others. Nevertheless, be aware that MS
946 Internet Explorer seems to be really buggy about cookies, at least till version
947 6. Even in a **single-user environment**, you might prefer to use :term:`HTTP`
948 or cookie mode so that your user/password pair are not in clear in the
951 :term:`HTTP` and cookie authentication
952 modes are more secure: the MySQL login information does not need to be
953 set in the phpMyAdmin configuration file (except possibly for the
954 :config:option:`$cfg['Servers'][$i]['controluser']`).
955 However, keep in mind that the password travels in plain text unless
956 you are using the HTTPS protocol. In cookie mode, the password is
957 stored, encrypted with the AES algorithm, in a temporary cookie.
959 Then each of the *true* users should be granted a set of privileges
960 on a set of particular databases. Normally you shouldn't give global
961 privileges to an ordinary user unless you understand the impact of those
962 privileges (for example, you are creating a superuser).
963 For example, to grant the user *real_user* with all privileges on
964 the database *user_base*:
966 .. code-block:: mysql
968 GRANT ALL PRIVILEGES ON user_base.* TO 'real_user'@localhost IDENTIFIED BY 'real_password';
970 What the user may now do is controlled entirely by the MySQL user management
971 system. With HTTP or cookie authentication mode, you don't need to fill the
972 user/password fields inside the :config:option:`$cfg['Servers']`.
982 .. index:: pair: HTTP; Authentication mode
986 HTTP authentication mode
987 ------------------------
989 * Uses :term:`HTTP` Basic authentication
990 method and allows you to log in as any valid MySQL user.
991 * Is supported with most PHP configurations. For :term:`IIS` (:term:`ISAPI`)
992 support using :term:`CGI` PHP see :ref:`faq1_32`, for using with Apache
993 :term:`CGI` see :ref:`faq1_35`.
994 * When PHP is running under Apache's :term:`mod_proxy_fcgi` (e.g. with PHP-FPM),
995 ``Authorization`` headers are not passed to the underlying FCGI application,
996 such that your credentials will not reach the application. In this case, you can
997 add the following configuration directive:
999 .. code-block:: apache
1001 SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
1003 * See also :ref:`faq4_4` about not using the :term:`.htaccess` mechanism along with
1004 ':term:`HTTP`' authentication mode.
1008 There is no way to do proper logout in HTTP authentication, most browsers
1009 will remember credentials until there is no different successful
1010 authentication. Because of this, this method has a limitation that you can not
1011 login with the same user after logout.
1013 .. index:: pair: Cookie; Authentication mode
1017 Cookie authentication mode
1018 --------------------------
1020 * Username and password are stored in cookies during the session and password
1021 is deleted when it ends.
1022 * With this mode, the user can truly log out of phpMyAdmin and log
1023 back in with the same username (this is not possible with :ref:`auth_http`).
1024 * If you want to allow users to enter any hostname to connect (rather than only
1025 servers that are configured in :file:`config.inc.php`),
1026 see the :config:option:`$cfg['AllowArbitraryServer']` directive.
1027 * As mentioned in the :ref:`require` section, having the ``openssl`` extension
1028 will speed up access considerably, but is not required.
1030 .. index:: pair: Signon; Authentication mode
1034 Signon authentication mode
1035 --------------------------
1037 * This mode is a convenient way of using credentials from another
1038 application to authenticate to phpMyAdmin to implement a single signon
1040 * The other application has to store login information into session
1041 data (see :config:option:`$cfg['Servers'][$i]['SignonSession']` and
1042 :config:option:`$cfg['Servers'][$i]['SignonCookieParams']`) or you
1043 need to implement script to return the credentials (see
1044 :config:option:`$cfg['Servers'][$i]['SignonScript']`).
1045 * When no credentials are available, the user is being redirected to
1046 :config:option:`$cfg['Servers'][$i]['SignonURL']`, where you should handle
1049 The very basic example of saving credentials in a session is available as
1050 :file:`examples/signon.php`:
1052 .. literalinclude:: ../examples/signon.php
1055 Alternatively, you can also use this way to integrate with OpenID as shown
1056 in :file:`examples/openid.php`:
1058 .. literalinclude:: ../examples/openid.php
1061 If you intend to pass the credentials using some other means than, you have to
1062 implement wrapper in PHP to get that data and set it to
1063 :config:option:`$cfg['Servers'][$i]['SignonScript']`. There is a very minimal example
1064 in :file:`examples/signon-script.php`:
1066 .. literalinclude:: ../examples/signon-script.php
1070 :config:option:`$cfg['Servers'][$i]['auth_type']`,
1071 :config:option:`$cfg['Servers'][$i]['SignonSession']`,
1072 :config:option:`$cfg['Servers'][$i]['SignonCookieParams']`,
1073 :config:option:`$cfg['Servers'][$i]['SignonScript']`,
1074 :config:option:`$cfg['Servers'][$i]['SignonURL']`,
1075 :ref:`example-signon`
1077 .. index:: pair: Config; Authentication mode
1081 Config authentication mode
1082 --------------------------
1084 * This mode is sometimes the less secure one because it requires you to fill the
1085 :config:option:`$cfg['Servers'][$i]['user']` and
1086 :config:option:`$cfg['Servers'][$i]['password']`
1087 fields (and as a result, anyone who can read your :file:`config.inc.php`
1088 can discover your username and password).
1089 * In the :ref:`faqmultiuser` section, there is an entry explaining how
1090 to protect your configuration file.
1091 * For additional security in this mode, you may wish to consider the
1092 Host authentication :config:option:`$cfg['Servers'][$i]['AllowDeny']['order']`
1093 and :config:option:`$cfg['Servers'][$i]['AllowDeny']['rules']` configuration directives.
1094 * Unlike cookie and http, does not require a user to log in when first
1095 loading the phpMyAdmin site. This is by design but could allow any
1096 user to access your installation. Use of some restriction method is
1097 suggested, perhaps a :term:`.htaccess` file with the HTTP-AUTH directive or disallowing
1098 incoming HTTP requests at one’s router or firewall will suffice (both
1099 of which are beyond the scope of this manual but easily searchable
1104 Securing your phpMyAdmin installation
1105 +++++++++++++++++++++++++++++++++++++
1107 The phpMyAdmin team tries hard to make the application secure, however there
1108 are always ways to make your installation more secure:
1110 * Follow our `Security announcements <https://www.phpmyadmin.net/security/>`_ and upgrade
1111 phpMyAdmin whenever new vulnerability is published.
1112 * Serve phpMyAdmin on HTTPS only. Preferably, you should use HSTS as well, so that
1113 you're protected from protocol downgrade attacks.
1114 * Ensure your PHP setup follows recommendations for production sites, for example
1115 `display_errors <https://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors>`_
1117 * Remove the ``test`` directory from phpMyAdmin, unless you are developing and need a test suite.
1118 * Remove the ``setup`` directory from phpMyAdmin, you will probably not
1119 use it after the initial setup.
1120 * Properly choose an authentication method - :ref:`cookie`
1121 is probably the best choice for shared hosting.
1122 * Deny access to auxiliary files in :file:`./libraries/` or
1123 :file:`./templates/` subfolders in your webserver configuration.
1124 Such configuration prevents from possible path exposure and cross side
1125 scripting vulnerabilities that might happen to be found in that code. For the
1126 Apache webserver, this is often accomplished with a :term:`.htaccess` file in
1128 * Deny access to temporary files, see :config:option:`$cfg['TempDir']` (if that
1129 is placed inside your web root, see also :ref:`web-dirs`.
1130 * It is generally a good idea to protect a public phpMyAdmin installation
1131 against access by robots as they usually can not do anything good there. You
1132 can do this using ``robots.txt`` file in the root of your webserver or limit
1133 access by web server configuration, see :ref:`faq1_42`.
1134 * In case you don't want all MySQL users to be able to access
1135 phpMyAdmin, you can use :config:option:`$cfg['Servers'][$i]['AllowDeny']['rules']` to limit them
1136 or :config:option:`$cfg['Servers'][$i]['AllowRoot']` to deny root user access.
1137 * Enable :ref:`2fa` for your account.
1138 * Consider hiding phpMyAdmin behind an authentication proxy, so that
1139 users need to authenticate prior to providing MySQL credentials
1140 to phpMyAdmin. You can achieve this by configuring your web server to request
1141 HTTP authentication. For example in Apache this can be done with:
1143 .. code-block:: apache
1146 AuthName "Restricted Access"
1147 AuthUserFile /usr/share/phpmyadmin/passwd
1150 Once you have changed the configuration, you need to create a list of users which
1151 can authenticate. This can be done using the :program:`htpasswd` utility:
1155 htpasswd -c /usr/share/phpmyadmin/passwd username
1157 * If you are afraid of automated attacks, enabling Captcha by
1158 :config:option:`$cfg['CaptchaLoginPublicKey']` and
1159 :config:option:`$cfg['CaptchaLoginPrivateKey']` might be an option.
1160 * Failed login attempts are logged to syslog (if available, see
1161 :config:option:`$cfg['AuthLog']`). This can allow using a tool such as
1162 fail2ban to block brute-force attempts. Note that the log file used by syslog
1163 is not the same as the Apache error or access log files.
1164 * In case you're running phpMyAdmin together with other PHP applications, it is
1165 generally advised to use separate session storage for phpMyAdmin to avoid
1166 possible session-based attacks against it. You can use
1167 :config:option:`$cfg['SessionSavePath']` to achieve this.
1171 Using SSL for connection to database server
1172 +++++++++++++++++++++++++++++++++++++++++++
1174 It is recommended to use SSL when connecting to remote database server. There
1175 are several configuration options involved in the SSL setup:
1177 :config:option:`$cfg['Servers'][$i]['ssl']`
1178 Defines whether to use SSL at all. If you enable only this, the connection
1179 will be encrypted, but there is not authentication of the connection - you
1180 can not verify that you are talking to the right server.
1181 :config:option:`$cfg['Servers'][$i]['ssl_key']` and :config:option:`$cfg['Servers'][$i]['ssl_cert']`
1182 This is used for authentication of client to the server.
1183 :config:option:`$cfg['Servers'][$i]['ssl_ca']` and :config:option:`$cfg['Servers'][$i]['ssl_ca_path']`
1184 The certificate authorities you trust for server certificates.
1185 This is used to ensure that you are talking to a trusted server.
1186 :config:option:`$cfg['Servers'][$i]['ssl_verify']`
1187 This configuration disables server certificate verification. Use with
1190 When the database server is using a local connection or private network and SSL can not be configured
1191 you can use :config:option:`$cfg['MysqlSslWarningSafeHosts']` to explicitly list the hostnames that are considered secure.
1195 :ref:`example-google-ssl`,
1196 :ref:`example-aws-ssl`,
1197 :config:option:`$cfg['Servers'][$i]['ssl']`,
1198 :config:option:`$cfg['Servers'][$i]['ssl_key']`,
1199 :config:option:`$cfg['Servers'][$i]['ssl_cert']`,
1200 :config:option:`$cfg['Servers'][$i]['ssl_ca']`,
1201 :config:option:`$cfg['Servers'][$i]['ssl_ca_path']`,
1202 :config:option:`$cfg['Servers'][$i]['ssl_ciphers']`,
1203 :config:option:`$cfg['Servers'][$i]['ssl_verify']`
1208 Users with column-specific privileges are unable to "Browse"
1209 ------------------------------------------------------------
1211 If a user has only column-specific privileges on some (but not all) columns in a table, "Browse"
1212 will fail with an error message.
1214 As a workaround, a bookmarked query with the same name as the table can be created, this will
1215 run when using the "Browse" link instead. `Issue 11922 <https://github.com/phpmyadmin/phpmyadmin/issues/11922>`_.
1217 Trouble logging back in after logging out using 'http' authentication
1218 ----------------------------------------------------------------------
1220 When using the 'http' ``auth_type``, it can be impossible to log back in (when the logout comes
1221 manually or after a period of inactivity). `Issue 11898 <https://github.com/phpmyadmin/phpmyadmin/issues/11898>`_.
1223 .. _Composer tool: https://getcomposer.org/
1224 .. _Packagist: https://packagist.org/
1225 .. _Docker official image: https://hub.docker.com/_/phpmyadmin