-尊龙登录

.. _setup: installation ============ phpmyadmin does not apply any special security methods to the mysql database server. it is still the system administrator's job to grant permissions on the mysql databases properly. phpmyadmin's :guilabel:`users` page can be used for this. linux distributions phpmyadmin is included in most linux distributions. it is recommended to use distribution packages when possible - they usually provide integration to your distribution and you will automatically get security updates from your distribution. .. _debian-package: debian and ubuntu ----------------- most debian and ubuntu versions include a phpmyadmin package, but be aware that the configuration file is maintained in ``/etc/phpmyadmin`` and may differ in some ways from the official phpmyadmin documentation. specifically, it does: * configuration of a web server (works for apache and lighttpd). * creating of :ref:`linked-tables` using dbconfig-common. * securing setup script, see :ref:`debian-setup`. more specific details about installing debian or ubuntu packages are available `in our wiki `_. .. seealso:: more information can be found in `readme.debian `_ (it is installed as :file:`/usr/share/doc/phpmyadmin/readme.debian` with the package). opensuse -------- opensuse already comes with phpmyadmin package, just install packages from the `opensuse build service `_. gentoo ------ gentoo ships the phpmyadmin package, both in a near-stock configuration as well as in a ``webapp-config`` configuration. use ``emerge dev-db/phpmyadmin`` to install. mandriva -------- mandriva ships the phpmyadmin package in their ``contrib`` branch and can be installed via the usual control center. fedora ------ fedora ships the phpmyadmin package, but be aware that the configuration file is maintained in ``/etc/phpmyadmin/`` and may differ in some ways from the official phpmyadmin documentation. red hat enterprise linux ------------------------ red hat enterprise linux itself and thus derivatives like centos don't ship phpmyadmin, but the fedora-driven repository `extra packages for enterprise linux (epel) `_ is doing so, if it's `enabled `_. but be aware that the configuration file is maintained in ``/etc/phpmyadmin/`` and may differ in some ways from the official phpmyadmin documentation. installing on windows the easiest way to get phpmyadmin on windows is using third party products which include phpmyadmin together with a database and web server such as `xampp `_. you can find more of such options at `wikipedia `_. installing from git in order to install from git, you'll need a few supporting applications: * `git `_ to download the source, or you can download the most recent source directly from `github `_ * `composer `__ * `node.js `_ (version 10 or higher) * `yarn `_ you can clone current phpmyadmin source from ``https://github.com/phpmyadmin/phpmyadmin.git``: .. code-block:: sh git clone https://github.com/phpmyadmin/phpmyadmin.git additionally you need to install dependencies using `composer `__: .. code-block:: sh composer update if you do not intend to develop, you can skip the installation of developer tools by invoking: .. code-block:: sh composer update --no-dev finally, you'll need to use `yarn`_ to install some javascript dependencies: .. code-block:: sh yarn install --production .. _composer: installing using composer you can install phpmyadmin using the `composer tool`_, since 4.7.0 the releases are automatically mirrored to the default `packagist`_ repository. .. note:: the content of the composer repository is automatically generated separately from the releases, so the content doesn't have to be 100% same as when you download the tarball. there should be no functional differences though. to install phpmyadmin simply run: .. code-block:: sh composer create-project phpmyadmin/phpmyadmin alternatively you can use our own composer repository, which contains the release tarballs and is available at : .. code-block:: sh composer create-project phpmyadmin/phpmyadmin --repository-url=https://www.phpmyadmin.net/packages.json --no-dev .. _docker: installing using docker phpmyadmin comes with a `docker official image`_, which you can easily deploy. you can download it using: .. code-block:: sh docker pull phpmyadmin the phpmyadmin server will listen on port 80. it supports several ways of configuring the link to the database server, either by docker's link feature by linking your database container to ``db`` for phpmyadmin (by specifying ``--link your_db_host:db``) or by environment variables (in this case it's up to you to set up networking in docker to allow the phpmyadmin container to access the database container over the network). .. _docker-vars: docker environment variables ---------------------------- you can configure several phpmyadmin features using environment variables: .. envvar:: pma_arbitrary allows you to enter a database server hostname on login form. .. seealso:: :config:option:`$cfg['allowarbitraryserver']` .. envvar:: pma_host hostname or ip address of the database server to use. .. seealso:: :config:option:`$cfg['servers'][$i]['host']` .. envvar:: pma_hosts comma-separated hostnames or ip addresses of the database servers to use. .. note:: used only if :envvar:`pma_host` is empty. .. envvar:: pma_verbose verbose name of the database server. .. seealso:: :config:option:`$cfg['servers'][$i]['verbose']` .. envvar:: pma_verboses comma-separated verbose name of the database servers. .. note:: used only if :envvar:`pma_verbose` is empty. .. envvar:: pma_user user name to use for :ref:`auth_config`. .. envvar:: pma_password password to use for :ref:`auth_config`. .. envvar:: pma_port port of the database server to use. .. envvar:: pma_ports comma-separated ports of the database server to use. .. note:: used only if :envvar:`pma_port` is empty. .. envvar:: pma_absolute_uri the fully-qualified path (``https://pma.example.net/``) where the reverse proxy makes phpmyadmin available. .. seealso:: :config:option:`$cfg['pmaabsoluteuri']` .. envvar:: hide_php_version if defined, this option will hide the php version (`expose_php = off`). set to any value (such as `hide_php_version=true`). .. envvar:: upload_limit 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). .. note:: format as `[0-9 ](k,m,g)` default value is `2048k` .. envvar:: pma_config_base64 if set, this option will override the default `config.inc.php` with the base64 decoded contents of the variable. .. envvar:: pma_user_config_base64 if set, this option will override the default `config.user.inc.php` with the base64 decoded contents of the variable. by default, :ref:`cookie` is used, but if :envvar:`pma_user` and :envvar:`pma_password` are set, it is switched to :ref:`auth_config`. .. note:: the credentials you need to log in are stored in the mysql server, in case of docker image, there are various ways to set it (for example :samp:`mysql_root_password` when starting the mysql container). please check documentation for `mariadb container `_ or `mysql container `_. .. _docker-custom: customizing configuration ------------------------- additionally configuration can be tweaked by :file:`/etc/phpmyadmin/config.user.inc.php`. if this file exists, it will be loaded after configuration is generated from above environment variables, so you can override any configuration variable. this configuration can be added as a volume when invoking docker using `-v /some/local/directory/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php` parameters. note that the supplied configuration file is applied after :ref:`docker-vars`, but you can override any of the values. for example to change the default behavior of csv export you can use the following configuration file: .. code-block:: php [ 'auth_type' => 'cookie', 'host' => 'mydb1', 'port' => 3306, 'verbose' => 'verbose name 1', ], 2 => [ 'auth_type' => 'cookie', 'host' => 'mydb2', 'port' => 3306, 'verbose' => 'verbose name 2', ], ]; .. seealso:: see :ref:`config` for detailed description of configuration options. docker volumes -------------- you can use the following volumes to customize image behavior: :file:`/etc/phpmyadmin/config.user.inc.php` can be used for additional settings, see the previous chapter for more details. :file:`/sessions/` directory where php sessions are stored. you might want to share this for example when using :ref:`auth_signon`. :file:`/www/themes/` directory where phpmyadmin looks for themes. by default only those shipped with phpmyadmin are included, but you can include additional phpmyadmin themes (see :ref:`themes`) by using docker volumes. docker examples --------------- to connect phpmyadmin to a given server use: .. code-block:: sh docker run --name myadmin -d -e pma_host=dbhost -p 8080:80 phpmyadmin/phpmyadmin to connect phpmyadmin to more servers use: .. code-block:: sh docker run --name myadmin -d -e pma_hosts=dbhost1,dbhost2,dbhost3 -p 8080:80 phpmyadmin/phpmyadmin to use arbitrary server option: .. code-block:: sh docker run --name myadmin -d --link mysql_db_server:db -p 8080:80 -e pma_arbitrary=1 phpmyadmin/phpmyadmin you can also link the database container using docker: .. code-block:: sh docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 phpmyadmin/phpmyadmin running with additional configuration: .. code-block:: sh 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 running with additional themes: .. code-block:: sh docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 -v /custom/phpmyadmin/theme/:/www/themes/theme/ phpmyadmin/phpmyadmin using docker-compose -------------------- alternatively, you can also use docker-compose with the docker-compose.yml from . this will run phpmyadmin with an arbitrary server - allowing you to specify mysql/mariadb server on the login page. .. code-block:: sh docker-compose up -d customizing configuration file using docker-compose --------------------------------------------------- you can use an external file to customize phpmyadmin configuration and pass it using the volumes directive: .. code-block:: yaml phpmyadmin: image: phpmyadmin/phpmyadmin container_name: phpmyadmin environment: - pma_arbitrary=1 restart: always ports: - 8080:80 volumes: - /sessions - ~/docker/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php - /custom/phpmyadmin/theme/:/www/themes/theme/ .. seealso:: :ref:`docker-custom` running behind haproxy in a subdirectory ---------------------------------------- when you want to expose phpmyadmin running in a docker container in a subdirectory, you need to rewrite the request path in the server proxying the requests. for example, using haproxy it can be done as: .. code-block:: text frontend http bind *:80 option forwardfor option http-server-close ### network restriction acl localnet src 10.0.0.0/8 192.168.0.0/16 172.16.0.0/12 # /phpmyadmin acl phpmyadmin path_dir /phpmyadmin use_backend phpmyadmin if phpmyadmin localnet backend phpmyadmin mode http reqirep ^(get|post|head)\ /phpmyadmin/(.*) \1\ /\2 # phpmyadmin container ip server localhost 172.30.21.21:80 when using traefik, something like following should work: .. code-block:: text defaultentrypoints = ["http"] [entrypoints] [entrypoints.http] address = ":80" [entrypoints.http.redirect] regex = "(http:\\/\\/[^\\/] \\/([^\\?\\.] )[^\\/])$" replacement = "$1/" [backends] [backends.myadmin] [backends.myadmin.servers.myadmin] url="http://internal.address.to.pma" [frontends] [frontends.myadmin] backend = "myadmin" passhostheader = true [frontends.myadmin.routes.default] rule="pathprefixstrip:/phpmyadmin/;addprefix:/" you then should specify :envvar:`pma_absolute_uri` in the docker-compose configuration: .. code-block:: yaml version: '2' services: phpmyadmin: restart: always image: phpmyadmin/phpmyadmin container_name: phpmyadmin hostname: phpmyadmin domainname: example.com ports: - 8000:80 environment: - pma_hosts=172.26.36.7,172.26.36.8,172.26.36.9,172.26.36.10 - pma_verboses=production-db1,production-db2,dev-db1,dev-db2 - pma_user=root - pma_password= - pma_absolute_uri=http://example.com/phpmyadmin/ ibm cloud one of our users has created a helpful guide for installing phpmyadmin on the `ibm cloud platform `_. .. _quick_install: quick install #. choose an appropriate distribution kit from the phpmyadmin.net downloads page. some kits contain only the english messages, others contain all languages. we'll assume you chose a kit whose name looks like ``phpmyadmin-x.x.x -all-languages.tar.gz``. #. ensure you have downloaded a genuine archive, see :ref:`verify`. #. untar or unzip the distribution (be sure to unzip the subdirectories): ``tar -xzvf phpmyadmin_x.x.x-all-languages.tar.gz`` in your webserver's document root. if you don't have direct access to your document root, put the files in a directory on your local machine, and, after step 4, transfer the directory on your web server using, for example, ftp. #. ensure that all the scripts have the appropriate owner (if php is running in safe mode, having some scripts with an owner different from the owner of other scripts will be a problem). see :ref:`faq4_2` and :ref:`faq1_26` for suggestions. #. now you must configure your installation. there are two methods that can be used. traditionally, users have hand-edited a copy of :file:`config.inc.php`, but now a wizard-style setup script is provided for those who prefer a graphical installation. creating a :file:`config.inc.php` is still a quick way to get started and needed for some advanced features. manually creating the file -------------------------- to manually create the file, simply use your text editor to create the file :file:`config.inc.php` (you can copy :file:`config.sample.inc.php` to get a minimal configuration file) in the main (top-level) phpmyadmin directory (the one that contains :file:`index.php`). phpmyadmin first loads the default configuration values and then overrides those values with anything found in :file:`config.inc.php`. if the default value is okay for a particular setting, there is no need to include it in :file:`config.inc.php`. you'll probably need only a few directives to get going; a simple configuration may look like this: .. code-block:: xml php or use setup script on our demo server: . .. _verify: verifying phpmyadmin releases since july 2015 all phpmyadmin releases are cryptographically signed by the releasing developer, who through january 2016 was marc delisle. his key id is 0xfefc65d181af644a, his pgp fingerprint is: .. code-block:: console 436f f188 4b1a 0c3f dcbf 0d79 fefc 65d1 81af 644a and you can get more identification information from . beginning in january 2016, the release manager is isaac bennetch. his key id is 0xce752f178259bd92, and his pgp fingerprint is: .. code-block:: console 3d06 a59e ce73 0eb7 1b51 1c17 ce75 2f17 8259 bd92 and you can get more identification information from . some additional downloads (for example themes) might be signed by michal čihař. his key id is 0x9c27b31342b7511d, and his pgp fingerprint is: .. code-block:: console 63cb 1df1 ef12 cf2a c0ee 5a32 9c27 b313 42b7 511d and you can get more identification information from . you should verify that the signature matches the archive you have downloaded. this way you can be sure that you are using the same code that was released. you should also verify the date of the signature to make sure that you downloaded the latest version. each archive is accompanied by ``.asc`` files which contain the pgp signature for it. once you have both of them in the same folder, you can verify the signature: .. code-block:: console $ gpg --verify phpmyadmin-4.5.4.1-all-languages.zip.asc gpg: signature made fri 29 jan 2016 08:59:37 am est using rsa key id 8259bd92 gpg: can't check signature: public key not found as you can see gpg complains that it does not know the public key. at this point, you should do one of the following steps: * download the keyring from `our download server `_, then import it with: .. code-block:: console $ gpg --import phpmyadmin.keyring * download and import the key from one of the key servers: .. code-block:: console $ gpg --keyserver hkp://pgp.mit.edu --recv-keys 3d06a59ece730eb71b511c17ce752f178259bd92 gpg: requesting key 8259bd92 from hkp server pgp.mit.edu gpg: key 8259bd92: public key "isaac bennetch " imported gpg: no ultimately trusted keys found gpg: total number processed: 1 gpg: imported: 1 (rsa: 1) this will improve the situation a bit - at this point, you can verify that the signature from the given key is correct but you still can not trust the name used in the key: .. code-block:: console $ gpg --verify phpmyadmin-4.5.4.1-all-languages.zip.asc gpg: signature made fri 29 jan 2016 08:59:37 am est using rsa key id 8259bd92 gpg: good signature from "isaac bennetch " gpg: aka "isaac bennetch " gpg: warning: this key is not certified with a trusted signature! gpg: there is no indication that the signature belongs to the owner. primary key fingerprint: 3d06 a59e ce73 0eb7 1b51 1c17 ce75 2f17 8259 bd92 the problem here is that anybody could issue the key with this name. you need to ensure that the key is actually owned by the mentioned person. the gnu privacy handbook covers this topic in the chapter `validating other keys on your public keyring`_. the most reliable method is to meet the developer in person and exchange key fingerprints, however, you can also rely on the web of trust. this way you can trust the key transitively though signatures of others, who have met the developer in person. once the key is trusted, the warning will not occur: .. code-block:: console $ gpg --verify phpmyadmin-4.5.4.1-all-languages.zip.asc gpg: signature made fri 29 jan 2016 08:59:37 am est using rsa key id 8259bd92 gpg: good signature from "isaac bennetch " [full] should the signature be invalid (the archive has been changed), you would get a clear error regardless of the fact that the key is trusted or not: .. code-block:: console $ gpg --verify phpmyadmin-4.5.4.1-all-languages.zip.asc gpg: signature made fri 29 jan 2016 08:59:37 am est using rsa key id 8259bd92 gpg: bad signature from "isaac bennetch " [unknown] .. _validating other keys on your public keyring: https://www.gnupg.org/gph/en/manual.html#aen335 .. index:: single: configuration storage single: phpmyadmin configuration storage single: pmadb .. _linked-tables: phpmyadmin configuration storage .. versionchanged:: 3.4.0 prior to phpmyadmin 3.4.0 this was called linked tables infrastructure, but the name was changed due to the extended scope of the storage. for a whole set of additional features (:ref:`bookmarks`, comments, :term:`sql`-history, tracking mechanism, :term:`pdf`-generation, :ref:`transformations`, :ref:`relations` etc.) you need to create a set of special tables. those tables can be located in your own database, or in a central database for a multi-user installation (this database would then be accessed by the controluser, so no other user should have rights to it). .. _zeroconf: zero configuration ------------------ in many cases, this database structure can be automatically created and configured. this is called “zero configuration” mode and can be particularly useful in shared hosting situations. “zeroconf” mode is on by default, to disable set :config:option:`$cfg['zeroconf']` to false. the following three scenarios are covered by the zero configuration mode: * when entering a database where the configuration storage tables are not present, phpmyadmin offers to create them from the operations tab. * when entering a database where the tables do already exist, the software automatically detects this and begins using them. this is the most common situation; after the tables are initially created automatically they are continually used without disturbing the user; this is also most useful on shared hosting where the user is not able to edit :file:`config.inc.php` and usually the user only has access to one database. * when having access to multiple databases, if the user first enters the database containing the configuration storage tables then switches to another database, phpmyadmin continues to use the tables from the first database; the user is not prompted to create more tables in the new database. manual configuration -------------------- please look at your ``./sql/`` directory, where you should find a file called *create\_tables.sql*. (if you are using a windows server, pay special attention to :ref:`faq1_23`). if you already had this infrastructure and: * upgraded to mysql 4.1.2 or newer, please use :file:`sql/upgrade_tables_mysql_4_1_2 .sql`. * upgraded to phpmyadmin 4.3.0 or newer from 2.5.0 or newer (<= 4.2.x), please use :file:`sql/upgrade_column_info_4_3_0 .sql`. * upgraded to phpmyadmin 4.7.0 or newer from 4.3.0 or newer, please use :file:`sql/upgrade_tables_4_7_0 .sql`. and then create new tables by importing :file:`sql/create_tables.sql`. you can use your phpmyadmin to create the tables for you. please be aware that you may need special (administrator) privileges to create the database and tables, and that the script may need some tuning, depending on the database name. after having imported the :file:`sql/create_tables.sql` file, you should specify the table names in your :file:`config.inc.php` file. the directives used for that can be found in the :ref:`config`. you will also need to have a controluser (:config:option:`$cfg['servers'][$i]['controluser']` and :config:option:`$cfg['servers'][$i]['controlpass']` settings) with the proper rights to those tables. for example you can create it using following statement: and for any mariadb version: .. code-block:: mysql create user 'pma'@'localhost' identified via mysql_native_password using 'pmapass'; grant select, insert, update, delete on ``.* to 'pma'@'localhost'; for mysql 8.0 and newer: .. code-block:: mysql create user 'pma'@'localhost' identified with caching_sha2_password by 'pmapass'; grant select, insert, update, delete on .* to 'pma'@'localhost'; for mysql older than 8.0: .. code-block:: mysql create user 'pma'@'localhost' identified with mysql_native_password as 'pmapass'; grant select, insert, update, delete on .* to 'pma'@'localhost'; note that mysql installations with php older than 7.4 and mysql newer than 8.0 may require using the mysql_native_password authentication as a workaround, see :ref:`faq1_45` for details. .. _upgrading: upgrading from an older version .. warning:: **never** extract the new version over an existing installation of phpmyadmin, always first remove the old files keeping just the configuration. this way, you will not leave any old or outdated files in the directory, which can have severe security implications or can cause various breakages. simply copy :file:`config.inc.php` from your previous installation into the newly unpacked one. configuration files from old versions may require some tweaking as some options have been changed or removed. for compatibility with php 5.3 and later, remove a ``set_magic_quotes_runtime(0);`` statement that you might find near the end of your configuration file. the complete upgrade can be performed in a few simple steps: 1. download the latest phpmyadmin version from . 2. rename existing phpmyadmin folder (for example to ``phpmyadmin-old``). 3. unpack freshly downloaded phpmyadmin to the desired location (for example ``phpmyadmin``). 4. copy :file:`config.inc.php`` from old location (``phpmyadmin-old``) to the new one (``phpmyadmin``). 5. test that everything works properly. 6. remove backup of a previous version (``phpmyadmin-old``). if you have upgraded your mysql server from a version previous to 4.1.2 to version 5.x or newer and if you use the phpmyadmin configuration storage, you should run the :term:`sql` script found in :file:`sql/upgrade_tables_mysql_4_1_2 .sql`. if you have upgraded your phpmyadmin to 4.3.0 or newer from 2.5.0 or newer (<= 4.2.x) and if you use the phpmyadmin configuration storage, you should run the :term:`sql` script found in :file:`sql/upgrade_column_info_4_3_0 .sql`. do not forget to clear the browser cache and to empty the old session by logging out and logging in again. .. index:: authentication mode .. _authentication_modes: using authentication modes :term:`http` and cookie authentication modes are recommended in a **multi-user environment** where you want to give users access to their own database and don't want them to play around with others. nevertheless, be aware that ms internet explorer seems to be really buggy about cookies, at least till version 6. even in a **single-user environment**, you might prefer to use :term:`http` or cookie mode so that your user/password pair are not in clear in the configuration file. :term:`http` and cookie authentication modes are more secure: the mysql login information does not need to be set in the phpmyadmin configuration file (except possibly for the :config:option:`$cfg['servers'][$i]['controluser']`). however, keep in mind that the password travels in plain text unless you are using the https protocol. in cookie mode, the password is stored, encrypted with the aes algorithm, in a temporary cookie. then each of the *true* users should be granted a set of privileges on a set of particular databases. normally you shouldn't give global privileges to an ordinary user unless you understand the impact of those privileges (for example, you are creating a superuser). for example, to grant the user *real_user* with all privileges on the database *user_base*: .. code-block:: mysql grant all privileges on user_base.* to 'real_user'@localhost identified by 'real_password'; what the user may now do is controlled entirely by the mysql user management system. with http or cookie authentication mode, you don't need to fill the user/password fields inside the :config:option:`$cfg['servers']`. .. seealso:: :ref:`faq1_32`, :ref:`faq1_35`, :ref:`faq4_1`, :ref:`faq4_2`, :ref:`faq4_3` .. index:: pair: http; authentication mode .. _auth_http: http authentication mode ------------------------ * uses :term:`http` basic authentication method and allows you to log in as any valid mysql user. * is supported with most php configurations. for :term:`iis` (:term:`isapi`) support using :term:`cgi` php see :ref:`faq1_32`, for using with apache :term:`cgi` see :ref:`faq1_35`. * when php is running under apache's :term:`mod_proxy_fcgi` (e.g. with php-fpm), ``authorization`` headers are not passed to the underlying fcgi application, such that your credentials will not reach the application. in this case, you can add the following configuration directive: .. code-block:: apache setenvif authorization "(.*)" http_authorization=$1 * see also :ref:`faq4_4` about not using the :term:`.htaccess` mechanism along with ':term:`http`' authentication mode. .. note:: there is no way to do proper logout in http authentication, most browsers will remember credentials until there is no different successful authentication. because of this, this method has a limitation that you can not login with the same user after logout. .. index:: pair: cookie; authentication mode .. _cookie: cookie authentication mode -------------------------- * username and password are stored in cookies during the session and password is deleted when it ends. * with this mode, the user can truly log out of phpmyadmin and log back in with the same username (this is not possible with :ref:`auth_http`). * if you want to allow users to enter any hostname to connect (rather than only servers that are configured in :file:`config.inc.php`), see the :config:option:`$cfg['allowarbitraryserver']` directive. * as mentioned in the :ref:`require` section, having the ``openssl`` extension will speed up access considerably, but is not required. .. index:: pair: signon; authentication mode .. _auth_signon: signon authentication mode -------------------------- * this mode is a convenient way of using credentials from another application to authenticate to phpmyadmin to implement a single signon solution. * the other application has to store login information into session data (see :config:option:`$cfg['servers'][$i]['signonsession']` and :config:option:`$cfg['servers'][$i]['signoncookieparams']`) or you need to implement script to return the credentials (see :config:option:`$cfg['servers'][$i]['signonscript']`). * when no credentials are available, the user is being redirected to :config:option:`$cfg['servers'][$i]['signonurl']`, where you should handle the login process. the very basic example of saving credentials in a session is available as :file:`examples/signon.php`: .. literalinclude:: ../examples/signon.php :language: php alternatively, you can also use this way to integrate with openid as shown in :file:`examples/openid.php`: .. literalinclude:: ../examples/openid.php :language: php if you intend to pass the credentials using some other means than, you have to implement wrapper in php to get that data and set it to :config:option:`$cfg['servers'][$i]['signonscript']`. there is a very minimal example in :file:`examples/signon-script.php`: .. literalinclude:: ../examples/signon-script.php :language: php .. seealso:: :config:option:`$cfg['servers'][$i]['auth_type']`, :config:option:`$cfg['servers'][$i]['signonsession']`, :config:option:`$cfg['servers'][$i]['signoncookieparams']`, :config:option:`$cfg['servers'][$i]['signonscript']`, :config:option:`$cfg['servers'][$i]['signonurl']`, :ref:`example-signon` .. index:: pair: config; authentication mode .. _auth_config: config authentication mode -------------------------- * this mode is sometimes the less secure one because it requires you to fill the :config:option:`$cfg['servers'][$i]['user']` and :config:option:`$cfg['servers'][$i]['password']` fields (and as a result, anyone who can read your :file:`config.inc.php` can discover your username and password). * in the :ref:`faqmultiuser` section, there is an entry explaining how to protect your configuration file. * for additional security in this mode, you may wish to consider the host authentication :config:option:`$cfg['servers'][$i]['allowdeny']['order']` and :config:option:`$cfg['servers'][$i]['allowdeny']['rules']` configuration directives. * unlike cookie and http, does not require a user to log in when first loading the phpmyadmin site. this is by design but could allow any user to access your installation. use of some restriction method is suggested, perhaps a :term:`.htaccess` file with the http-auth directive or disallowing incoming http requests at one’s router or firewall will suffice (both of which are beyond the scope of this manual but easily searchable with google). .. _securing: securing your phpmyadmin installation the phpmyadmin team tries hard to make the application secure, however there are always ways to make your installation more secure: * follow our `security announcements `_ and upgrade phpmyadmin whenever new vulnerability is published. * serve phpmyadmin on https only. preferably, you should use hsts as well, so that you're protected from protocol downgrade attacks. * ensure your php setup follows recommendations for production sites, for example `display_errors `_ should be disabled. * remove the ``test`` directory from phpmyadmin, unless you are developing and need a test suite. * remove the ``setup`` directory from phpmyadmin, you will probably not use it after the initial setup. * properly choose an authentication method - :ref:`cookie` is probably the best choice for shared hosting. * deny access to auxiliary files in :file:`./libraries/` or :file:`./templates/` subfolders in your webserver configuration. such configuration prevents from possible path exposure and cross side scripting vulnerabilities that might happen to be found in that code. for the apache webserver, this is often accomplished with a :term:`.htaccess` file in those directories. * deny access to temporary files, see :config:option:`$cfg['tempdir']` (if that is placed inside your web root, see also :ref:`web-dirs`. * it is generally a good idea to protect a public phpmyadmin installation against access by robots as they usually can not do anything good there. you can do this using ``robots.txt`` file in the root of your webserver or limit access by web server configuration, see :ref:`faq1_42`. * in case you don't want all mysql users to be able to access phpmyadmin, you can use :config:option:`$cfg['servers'][$i]['allowdeny']['rules']` to limit them or :config:option:`$cfg['servers'][$i]['allowroot']` to deny root user access. * enable :ref:`2fa` for your account. * consider hiding phpmyadmin behind an authentication proxy, so that users need to authenticate prior to providing mysql credentials to phpmyadmin. you can achieve this by configuring your web server to request http authentication. for example in apache this can be done with: .. code-block:: apache authtype basic authname "restricted access" authuserfile /usr/share/phpmyadmin/passwd require valid-user once you have changed the configuration, you need to create a list of users which can authenticate. this can be done using the :program:`htpasswd` utility: .. code-block:: sh htpasswd -c /usr/share/phpmyadmin/passwd username * if you are afraid of automated attacks, enabling captcha by :config:option:`$cfg['captchaloginpublickey']` and :config:option:`$cfg['captchaloginprivatekey']` might be an option. * failed login attempts are logged to syslog (if available, see :config:option:`$cfg['authlog']`). this can allow using a tool such as fail2ban to block brute-force attempts. note that the log file used by syslog is not the same as the apache error or access log files. * in case you're running phpmyadmin together with other php applications, it is generally advised to use separate session storage for phpmyadmin to avoid possible session-based attacks against it. you can use :config:option:`$cfg['sessionsavepath']` to achieve this. .. _ssl: using ssl for connection to database server it is recommended to use ssl when connecting to remote database server. there are several configuration options involved in the ssl setup: :config:option:`$cfg['servers'][$i]['ssl']` defines whether to use ssl at all. if you enable only this, the connection will be encrypted, but there is not authentication of the connection - you can not verify that you are talking to the right server. :config:option:`$cfg['servers'][$i]['ssl_key']` and :config:option:`$cfg['servers'][$i]['ssl_cert']` this is used for authentication of client to the server. :config:option:`$cfg['servers'][$i]['ssl_ca']` and :config:option:`$cfg['servers'][$i]['ssl_ca_path']` the certificate authorities you trust for server certificates. this is used to ensure that you are talking to a trusted server. :config:option:`$cfg['servers'][$i]['ssl_verify']` this configuration disables server certificate verification. use with caution. when the database server is using a local connection or private network and ssl can not be configured you can use :config:option:`$cfg['mysqlsslwarningsafehosts']` to explicitly list the hostnames that are considered secure. .. seealso:: :ref:`example-google-ssl`, :ref:`example-aws-ssl`, :config:option:`$cfg['servers'][$i]['ssl']`, :config:option:`$cfg['servers'][$i]['ssl_key']`, :config:option:`$cfg['servers'][$i]['ssl_cert']`, :config:option:`$cfg['servers'][$i]['ssl_ca']`, :config:option:`$cfg['servers'][$i]['ssl_ca_path']`, :config:option:`$cfg['servers'][$i]['ssl_ciphers']`, :config:option:`$cfg['servers'][$i]['ssl_verify']` known issues users with column-specific privileges are unable to "browse" ------------------------------------------------------------ if a user has only column-specific privileges on some (but not all) columns in a table, "browse" will fail with an error message. as a workaround, a bookmarked query with the same name as the table can be created, this will run when using the "browse" link instead. `issue 11922 `_. trouble logging back in after logging out using 'http' authentication ---------------------------------------------------------------------- when using the 'http' ``auth_type``, it can be impossible to log back in (when the logout comes manually or after a period of inactivity). `issue 11898 `_. .. _composer tool: https://getcomposer.org/ .. _packagist: https://packagist.org/ .. _docker official image: https://hub.docker.com/_/phpmyadmin
网站地图