setup.rst.txt 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117
  1. .. _setup:
  2. Installation
  3. ============
  4. phpMyAdmin does not apply any special security methods to the MySQL
  5. database server. It is still the system administrator's job to grant
  6. permissions on the MySQL databases properly. phpMyAdmin's :guilabel:`Users`
  7. page can be used for this.
  8. .. warning::
  9. :term:`Mac` users should note that if you are on a version before
  10. :term:`Mac OS X`, StuffIt unstuffs with :term:`Mac` formats. So you'll have
  11. to resave as in BBEdit to Unix style ALL phpMyAdmin scripts before
  12. uploading them to your server, as PHP seems not to like :term:`Mac`-style
  13. end of lines character ("``\r``").
  14. Linux distributions
  15. +++++++++++++++++++
  16. phpMyAdmin is included in most Linux distributions. It is recommended to use
  17. distribution packages when possible - they usually provide integration to your
  18. distribution and you will automatically get security updates from your distribution.
  19. .. _debian-package:
  20. Debian and Ubuntu
  21. -----------------
  22. Debian's package repositories include a phpMyAdmin package, but be aware that
  23. the configuration file is maintained in ``/etc/phpmyadmin`` and may differ in
  24. some ways from the official phpMyAdmin documentation. Specifically, it does:
  25. * Configuration of a web server (works for Apache and lighttpd).
  26. * Creating of :ref:`linked-tables` using dbconfig-common.
  27. * Securing setup script, see :ref:`debian-setup`.
  28. .. seealso::
  29. More information can be found in `README.Debian <https://salsa.debian.org/phpmyadmin-team/phpmyadmin/blob/master/debian/README.Debian>`_
  30. (it is installed as :file:`/usr/share/doc/phmyadmin/README.Debian` with the package).
  31. OpenSUSE
  32. --------
  33. OpenSUSE already comes with phpMyAdmin package, just install packages from
  34. the `openSUSE Build Service <https://software.opensuse.org/package/phpMyAdmin>`_.
  35. Gentoo
  36. ------
  37. Gentoo ships the phpMyAdmin package, both in a near-stock configuration as well
  38. as in a ``webapp-config`` configuration. Use ``emerge dev-db/phpmyadmin`` to
  39. install.
  40. Mandriva
  41. --------
  42. Mandriva ships the phpMyAdmin package in their ``contrib`` branch and can be
  43. installed via the usual Control Center.
  44. Fedora
  45. ------
  46. Fedora ships the phpMyAdmin package, but be aware that the configuration file
  47. is maintained in ``/etc/phpMyAdmin/`` and may differ in some ways from the
  48. official phpMyAdmin documentation.
  49. Red Hat Enterprise Linux
  50. ------------------------
  51. Red Hat Enterprise Linux itself and thus derivatives like CentOS don't
  52. ship phpMyAdmin, but the Fedora-driven repository
  53. `Extra Packages for Enterprise Linux (EPEL) <https://fedoraproject.org/wiki/EPEL>`_
  54. is doing so, if it's
  55. `enabled <https://fedoraproject.org/wiki/EPEL/FAQ#howtouse>`_.
  56. But be aware that the configuration file is maintained in
  57. ``/etc/phpMyAdmin/`` and may differ in some ways from the
  58. official phpMyAdmin documentation.
  59. Installing on Windows
  60. +++++++++++++++++++++
  61. The easiest way to get phpMyAdmin on Windows is using third party products
  62. which include phpMyAdmin together with a database and web server such as
  63. `XAMPP <https://www.apachefriends.org/index.html>`_.
  64. You can find more of such options at `Wikipedia <https://en.wikipedia.org/wiki/List_of_AMP_packages>`_.
  65. Installing from Git
  66. +++++++++++++++++++
  67. You can clone current phpMyAdmin source from
  68. ``https://github.com/phpmyadmin/phpmyadmin.git``:
  69. .. code-block:: sh
  70. git clone https://github.com/phpmyadmin/phpmyadmin.git
  71. Additionally you need to install dependencies using the `Composer tool`_:
  72. .. code-block:: sh
  73. composer update
  74. If you do not intend to develop, you can skip the installation of developer tools
  75. by invoking:
  76. .. code-block:: sh
  77. composer update --no-dev
  78. .. _composer:
  79. Installing using Composer
  80. +++++++++++++++++++++++++
  81. You can install phpMyAdmin using the `Composer tool`_, since 4.7.0 the releases
  82. are automatically mirrored to the default `Packagist`_ repository.
  83. .. note::
  84. The content of the Composer repository is automatically generated
  85. separately from the releases, so the content doesn't have to be
  86. 100% same as when you download the tarball. There should be no
  87. functional differences though.
  88. To install phpMyAdmin simply run:
  89. .. code-block:: sh
  90. composer create-project phpmyadmin/phpmyadmin
  91. Alternatively you can use our own composer repository, which contains
  92. the release tarballs and is available at
  93. <https://www.phpmyadmin.net/packages.json>:
  94. .. code-block:: sh
  95. composer create-project phpmyadmin/phpmyadmin --repository-url=https://www.phpmyadmin.net/packages.json --no-dev
  96. .. _docker:
  97. Installing using Docker
  98. +++++++++++++++++++++++
  99. phpMyAdmin comes with a `Docker image`_, which you can easily deploy. You can
  100. download it using:
  101. .. code-block:: sh
  102. docker pull phpmyadmin/phpmyadmin
  103. The phpMyAdmin server will listen on port 80. It supports several ways of
  104. configuring the link to the database server, either by Docker's link feature
  105. by linking your database container to ``db`` for phpMyAdmin (by specifying
  106. ``--link your_db_host:db``) or by environment variables (in this case it's up
  107. to you to set up networking in Docker to allow the phpMyAdmin container to access
  108. the database container over the network).
  109. .. _docker-vars:
  110. Docker environment variables
  111. ----------------------------
  112. You can configure several phpMyAdmin features using environment variables:
  113. .. envvar:: PMA_ARBITRARY
  114. Allows you to enter a database server hostname on login form.
  115. .. seealso:: :config:option:`$cfg['AllowArbitraryServer']`
  116. .. envvar:: PMA_HOST
  117. Hostname or IP address of the database server to use.
  118. .. seealso:: :config:option:`$cfg['Servers'][$i]['host']`
  119. .. envvar:: PMA_HOSTS
  120. Comma-separated hostnames or IP addresses of the database servers to use.
  121. .. note:: Used only if :envvar:`PMA_HOST` is empty.
  122. .. envvar:: PMA_VERBOSE
  123. Verbose name of the database server.
  124. .. seealso:: :config:option:`$cfg['Servers'][$i]['verbose']`
  125. .. envvar:: PMA_VERBOSES
  126. Comma-separated verbose name of the database servers.
  127. .. note:: Used only if :envvar:`PMA_VERBOSE` is empty.
  128. .. envvar:: PMA_USER
  129. User name to use for :ref:`auth_config`.
  130. .. envvar:: PMA_PASSWORD
  131. Password to use for :ref:`auth_config`.
  132. .. envvar:: PMA_PORT
  133. Port of the database server to use.
  134. .. envvar:: PMA_PORTS
  135. Comma-separated ports of the database server to use.
  136. .. note:: Used only if :envvar:`PMA_PORT` is empty.
  137. .. envvar:: PMA_ABSOLUTE_URI
  138. The fully-qualified path (``https://pma.example.net/``) where the reverse
  139. proxy makes phpMyAdmin available.
  140. .. seealso:: :config:option:`$cfg['PmaAbsoluteUri']`
  141. By default, :ref:`cookie` is used, but if :envvar:`PMA_USER` and
  142. :envvar:`PMA_PASSWORD` are set, it is switched to :ref:`auth_config`.
  143. .. note::
  144. The credentials you need to log in are stored in the MySQL server, in case
  145. of Docker image, there are various ways to set it (for example
  146. :samp:`MYSQL_ROOT_PASSWORD` when starting the MySQL container). Please check
  147. documentation for `MariaDB container <https://hub.docker.com/_/mariadb>`_
  148. or `MySQL container <https://hub.docker.com/_/mysql>`_.
  149. .. _docker-custom:
  150. Customizing configuration
  151. -------------------------
  152. Additionally configuration can be tweaked by :file:`/etc/phpmyadmin/config.user.inc.php`. If
  153. this file exists, it will be loaded after configuration is generated from above
  154. environment variables, so you can override any configuration variable. This
  155. configuration can be added as a volume when invoking docker using
  156. `-v /some/local/directory/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php` parameters.
  157. Note that the supplied configuration file is applied after :ref:`docker-vars`,
  158. but you can override any of the values.
  159. For example to change the default behavior of CSV export you can use the following
  160. configuration file:
  161. .. code-block:: php
  162. <?php
  163. $cfg['Export']['csv_columns'] = true;
  164. ?>
  165. You can also use it to define server configuration instead of using the
  166. environment variables listed in :ref:`docker-vars`:
  167. .. code-block:: php
  168. <?php
  169. /* Override Servers array */
  170. $cfg['Servers'] = [
  171. 1 => [
  172. 'auth_type' => 'cookie',
  173. 'host' => 'mydb1',
  174. 'port' => 3306,
  175. 'verbose' => 'Verbose name 1',
  176. ],
  177. 2 => [
  178. 'auth_type' => 'cookie',
  179. 'host' => 'mydb2',
  180. 'port' => 3306,
  181. 'verbose' => 'Verbose name 2',
  182. ],
  183. ];
  184. .. seealso::
  185. See :ref:`config` for detailed description of configuration options.
  186. Docker Volumes
  187. --------------
  188. You can use the following volumes to customize image behavior:
  189. :file:`/etc/phpmyadmin/config.user.inc.php`
  190. Can be used for additional settings, see the previous chapter for more details.
  191. :file:`/sessions/`
  192. Directory where PHP sessions are stored. You might want to share this
  193. for example when using :ref:`auth_signon`.
  194. :file:`/www/themes/`
  195. Directory where phpMyAdmin looks for themes. By default only those shipped
  196. with phpMyAdmin are included, but you can include additional phpMyAdmin
  197. themes (see :ref:`themes`) by using Docker volumes.
  198. Docker Examples
  199. ---------------
  200. To connect phpMyAdmin to a given server use:
  201. .. code-block:: sh
  202. docker run --name myadmin -d -e PMA_HOST=dbhost -p 8080:80 phpmyadmin/phpmyadmin
  203. To connect phpMyAdmin to more servers use:
  204. .. code-block:: sh
  205. docker run --name myadmin -d -e PMA_HOSTS=dbhost1,dbhost2,dbhost3 -p 8080:80 phpmyadmin/phpmyadmin
  206. To use arbitrary server option:
  207. .. code-block:: sh
  208. docker run --name myadmin -d --link mysql_db_server:db -p 8080:80 -e PMA_ARBITRARY=1 phpmyadmin/phpmyadmin
  209. You can also link the database container using Docker:
  210. .. code-block:: sh
  211. docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 phpmyadmin/phpmyadmin
  212. Running with additional configuration:
  213. .. code-block:: sh
  214. 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
  215. Running with additional themes:
  216. .. code-block:: sh
  217. docker run --name phpmyadmin -d --link mysql_db_server:db -p 8080:80 -v /custom/phpmyadmin/theme/:/www/themes/theme/ phpmyadmin/phpmyadmin
  218. Using docker-compose
  219. --------------------
  220. Alternatively, you can also use docker-compose with the docker-compose.yml from
  221. <https://github.com/phpmyadmin/docker>. This will run phpMyAdmin with an
  222. arbitrary server - allowing you to specify MySQL/MariaDB server on the login page.
  223. .. code-block:: sh
  224. docker-compose up -d
  225. Customizing configuration file using docker-compose
  226. ---------------------------------------------------
  227. You can use an external file to customize phpMyAdmin configuration and pass it
  228. using the volumes directive:
  229. .. code-block:: yaml
  230. phpmyadmin:
  231. image: phpmyadmin/phpmyadmin
  232. container_name: phpmyadmin
  233. environment:
  234. - PMA_ARBITRARY=1
  235. restart: always
  236. ports:
  237. - 8080:80
  238. volumes:
  239. - /sessions
  240. - ~/docker/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
  241. - /custom/phpmyadmin/theme/:/www/themes/theme/
  242. .. seealso:: :ref:`docker-custom`
  243. Running behind haproxy in a subdirectory
  244. ----------------------------------------
  245. When you want to expose phpMyAdmin running in a Docker container in a
  246. subdirectory, you need to rewrite the request path in the server proxying the
  247. requests.
  248. For example, using haproxy it can be done as:
  249. .. code-block:: text
  250. frontend http
  251. bind *:80
  252. option forwardfor
  253. option http-server-close
  254. ### NETWORK restriction
  255. acl LOCALNET src 10.0.0.0/8 192.168.0.0/16 172.16.0.0/12
  256. # /phpmyadmin
  257. acl phpmyadmin path_dir /phpmyadmin
  258. use_backend phpmyadmin if phpmyadmin LOCALNET
  259. backend phpmyadmin
  260. mode http
  261. reqirep ^(GET|POST|HEAD)\ /phpmyadmin/(.*) \1\ /\2
  262. # phpMyAdmin container IP
  263. server localhost 172.30.21.21:80
  264. When using traefik, something like following should work:
  265. .. code-block:: text
  266. defaultEntryPoints = ["http"]
  267. [entryPoints]
  268. [entryPoints.http]
  269. address = ":80"
  270. [entryPoints.http.redirect]
  271. regex = "(http:\\/\\/[^\\/]+\\/([^\\?\\.]+)[^\\/])$"
  272. replacement = "$1/"
  273. [backends]
  274. [backends.myadmin]
  275. [backends.myadmin.servers.myadmin]
  276. url="http://internal.address.to.pma"
  277. [frontends]
  278. [frontends.myadmin]
  279. backend = "myadmin"
  280. passHostHeader = true
  281. [frontends.myadmin.routes.default]
  282. rule="PathPrefixStrip:/phpmyadmin/;AddPrefix:/"
  283. You then should specify :envvar:`PMA_ABSOLUTE_URI` in the docker-compose
  284. configuration:
  285. .. code-block:: yaml
  286. version: '2'
  287. services:
  288. phpmyadmin:
  289. restart: always
  290. image: phpmyadmin/phpmyadmin
  291. container_name: phpmyadmin
  292. hostname: phpmyadmin
  293. domainname: example.com
  294. ports:
  295. - 8000:80
  296. environment:
  297. - PMA_HOSTS=172.26.36.7,172.26.36.8,172.26.36.9,172.26.36.10
  298. - PMA_VERBOSES=production-db1,production-db2,dev-db1,dev-db2
  299. - PMA_USER=root
  300. - PMA_PASSWORD=
  301. - PMA_ABSOLUTE_URI=http://example.com/phpmyadmin/
  302. .. _quick_install:
  303. Quick Install
  304. +++++++++++++
  305. #. Choose an appropriate distribution kit from the phpmyadmin.net
  306. Downloads page. Some kits contain only the English messages, others
  307. contain all languages. We'll assume you chose a kit whose name
  308. looks like ``phpMyAdmin-x.x.x -all-languages.tar.gz``.
  309. #. Ensure you have downloaded a genuine archive, see :ref:`verify`.
  310. #. Untar or unzip the distribution (be sure to unzip the subdirectories):
  311. ``tar -xzvf phpMyAdmin_x.x.x-all-languages.tar.gz`` in your
  312. webserver's document root. If you don't have direct access to your
  313. document root, put the files in a directory on your local machine,
  314. and, after step 4, transfer the directory on your web server using,
  315. for example, ftp.
  316. #. Ensure that all the scripts have the appropriate owner (if PHP is
  317. running in safe mode, having some scripts with an owner different from
  318. the owner of other scripts will be a problem). See :ref:`faq4_2` and
  319. :ref:`faq1_26` for suggestions.
  320. #. Now you must configure your installation. There are two methods that
  321. can be used. Traditionally, users have hand-edited a copy of
  322. :file:`config.inc.php`, but now a wizard-style setup script is provided
  323. for those who prefer a graphical installation. Creating a
  324. :file:`config.inc.php` is still a quick way to get started and needed for
  325. some advanced features.
  326. Manually creating the file
  327. --------------------------
  328. To manually create the file, simply use your text editor to create the
  329. file :file:`config.inc.php` (you can copy :file:`config.sample.inc.php` to get
  330. a minimal configuration file) in the main (top-level) phpMyAdmin
  331. directory (the one that contains :file:`index.php`). phpMyAdmin first
  332. loads :file:`libraries/config.default.php` and then overrides those values
  333. with anything found in :file:`config.inc.php`. If the default value is
  334. okay for a particular setting, there is no need to include it in
  335. :file:`config.inc.php`. You'll probably need only a few directives to get going; a
  336. simple configuration may look like this:
  337. .. code-block:: xml+php
  338. <?php
  339. // use here a value of your choice at least 32 chars long
  340. $cfg['blowfish_secret'] = '1{dd0`<Q),5XP_:R9UK%%8\"EEcyH#{o';
  341. $i=0;
  342. $i++;
  343. $cfg['Servers'][$i]['auth_type'] = 'cookie';
  344. // if you insist on "root" having no password:
  345. // $cfg['Servers'][$i]['AllowNoPassword'] = true; `
  346. ?>
  347. Or, if you prefer to not be prompted every time you log in:
  348. .. code-block:: xml+php
  349. <?php
  350. $i=0;
  351. $i++;
  352. $cfg['Servers'][$i]['user'] = 'root';
  353. $cfg['Servers'][$i]['password'] = 'cbb74bc'; // use here your password
  354. $cfg['Servers'][$i]['auth_type'] = 'config';
  355. ?>
  356. .. warning::
  357. Storing passwords in the configuration is insecure as anybody can then
  358. manipulate your database.
  359. For a full explanation of possible configuration values, see the
  360. :ref:`config` of this document.
  361. .. index:: Setup script
  362. .. _setup_script:
  363. Using the Setup script
  364. ----------------------
  365. Instead of manually editing :file:`config.inc.php`, you can use phpMyAdmin's
  366. setup feature. The file can be generated using the setup and you can download it
  367. for upload to the server.
  368. Next, open your browser and visit the location where you installed phpMyAdmin,
  369. with the ``/setup`` suffix. The changes are not saved to the server, you need to
  370. use the :guilabel:`Download` button to save them to your computer and then upload
  371. to the server.
  372. Now the file is ready to be used. You can choose to review or edit the
  373. file with your favorite editor, if you prefer to set some advanced
  374. options that the setup script does not provide.
  375. #. If you are using the ``auth_type`` "config", it is suggested that you
  376. protect the phpMyAdmin installation directory because using config
  377. does not require a user to enter a password to access the phpMyAdmin
  378. installation. Use of an alternate authentication method is
  379. recommended, for example with HTTP–AUTH in a :term:`.htaccess` file or switch to using
  380. ``auth_type`` cookie or http. See the :ref:`faqmultiuser`
  381. for additional information, especially :ref:`faq4_4`.
  382. #. Open the main phpMyAdmin directory in your browser.
  383. phpMyAdmin should now display a welcome screen and your databases, or
  384. a login dialog if using :term:`HTTP` or
  385. cookie authentication mode.
  386. .. _debian-setup:
  387. Setup script on Debian, Ubuntu and derivatives
  388. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  389. Debian and Ubuntu have changed the way in which the setup script is enabled and disabled, in a way
  390. that single command has to be executed for either of these.
  391. To allow editing configuration invoke:
  392. .. code-block:: sh
  393. /usr/sbin/pma-configure
  394. To block editing configuration invoke:
  395. .. code-block:: sh
  396. /usr/sbin/pma-secure
  397. Setup script on openSUSE
  398. ~~~~~~~~~~~~~~~~~~~~~~~~
  399. Some openSUSE releases do not include setup script in the package. In case you
  400. want to generate configuration on these you can either download original
  401. package from <https://www.phpmyadmin.net/> or use setup script on our demo
  402. server: <https://demo.phpmyadmin.net/master/setup/>.
  403. .. _verify:
  404. Verifying phpMyAdmin releases
  405. +++++++++++++++++++++++++++++
  406. Since July 2015 all phpMyAdmin releases are cryptographically signed by the
  407. releasing developer, who through January 2016 was Marc Delisle. His key id is
  408. 0xFEFC65D181AF644A, his PGP fingerprint is:
  409. .. code-block:: console
  410. 436F F188 4B1A 0C3F DCBF 0D79 FEFC 65D1 81AF 644A
  411. and you can get more identification information from <https://keybase.io/lem9>.
  412. Beginning in January 2016, the release manager is Isaac Bennetch. His key id is
  413. 0xCE752F178259BD92, and his PGP fingerprint is:
  414. .. code-block:: console
  415. 3D06 A59E CE73 0EB7 1B51 1C17 CE75 2F17 8259 BD92
  416. and you can get more identification information from <https://keybase.io/ibennetch>.
  417. Some additional downloads (for example themes) might be signed by Michal Čihař. His key id is
  418. 0x9C27B31342B7511D, and his PGP fingerprint is:
  419. .. code-block:: console
  420. 63CB 1DF1 EF12 CF2A C0EE 5A32 9C27 B313 42B7 511D
  421. and you can get more identification information from <https://keybase.io/nijel>.
  422. You should verify that the signature matches the archive you have downloaded.
  423. This way you can be sure that you are using the same code that was released.
  424. You should also verify the date of the signature to make sure that you
  425. downloaded the latest version.
  426. Each archive is accompanied by ``.asc`` files which contain the PGP signature
  427. for it. Once you have both of them in the same folder, you can verify the signature:
  428. .. code-block:: console
  429. $ gpg --verify phpMyAdmin-4.5.4.1-all-languages.zip.asc
  430. gpg: Signature made Fri 29 Jan 2016 08:59:37 AM EST using RSA key ID 8259BD92
  431. gpg: Can't check signature: public key not found
  432. As you can see gpg complains that it does not know the public key. At this
  433. point, you should do one of the following steps:
  434. * Download the keyring from `our download server <https://files.phpmyadmin.net/phpmyadmin.keyring>`_, then import it with:
  435. .. code-block:: console
  436. $ gpg --import phpmyadmin.keyring
  437. * Download and import the key from one of the key servers:
  438. .. code-block:: console
  439. $ gpg --keyserver hkp://pgp.mit.edu --recv-keys 3D06A59ECE730EB71B511C17CE752F178259BD92
  440. gpg: requesting key 8259BD92 from hkp server pgp.mit.edu
  441. gpg: key 8259BD92: public key "Isaac Bennetch <bennetch@gmail.com>" imported
  442. gpg: no ultimately trusted keys found
  443. gpg: Total number processed: 1
  444. gpg: imported: 1 (RSA: 1)
  445. This will improve the situation a bit - at this point, you can verify that the
  446. signature from the given key is correct but you still can not trust the name used
  447. in the key:
  448. .. code-block:: console
  449. $ gpg --verify phpMyAdmin-4.5.4.1-all-languages.zip.asc
  450. gpg: Signature made Fri 29 Jan 2016 08:59:37 AM EST using RSA key ID 8259BD92
  451. gpg: Good signature from "Isaac Bennetch <bennetch@gmail.com>"
  452. gpg: aka "Isaac Bennetch <isaac@bennetch.org>"
  453. gpg: WARNING: This key is not certified with a trusted signature!
  454. gpg: There is no indication that the signature belongs to the owner.
  455. Primary key fingerprint: 3D06 A59E CE73 0EB7 1B51 1C17 CE75 2F17 8259 BD92
  456. The problem here is that anybody could issue the key with this name. You need to
  457. ensure that the key is actually owned by the mentioned person. The GNU Privacy
  458. Handbook covers this topic in the chapter `Validating other keys on your public
  459. keyring`_. The most reliable method is to meet the developer in person and
  460. exchange key fingerprints, however, you can also rely on the web of trust. This way
  461. you can trust the key transitively though signatures of others, who have met
  462. the developer in person. For example, you can see how `Isaac's key links to
  463. Linus's key`_.
  464. Once the key is trusted, the warning will not occur:
  465. .. code-block:: console
  466. $ gpg --verify phpMyAdmin-4.5.4.1-all-languages.zip.asc
  467. gpg: Signature made Fri 29 Jan 2016 08:59:37 AM EST using RSA key ID 8259BD92
  468. gpg: Good signature from "Isaac Bennetch <bennetch@gmail.com>" [full]
  469. Should the signature be invalid (the archive has been changed), you would get a
  470. clear error regardless of the fact that the key is trusted or not:
  471. .. code-block:: console
  472. $ gpg --verify phpMyAdmin-4.5.4.1-all-languages.zip.asc
  473. gpg: Signature made Fri 29 Jan 2016 08:59:37 AM EST using RSA key ID 8259BD92
  474. gpg: BAD signature from "Isaac Bennetch <bennetch@gmail.com>" [unknown]
  475. .. _Validating other keys on your public keyring: https://www.gnupg.org/gph/en/manual.html#AEN335
  476. .. _Isaac's key links to Linus's key: https://pgp.cs.uu.nl/paths/79be3e4300411886/to/ce752f178259bd92.html
  477. .. index::
  478. single: Configuration storage
  479. single: phpMyAdmin configuration storage
  480. single: pmadb
  481. .. _linked-tables:
  482. phpMyAdmin configuration storage
  483. ++++++++++++++++++++++++++++++++
  484. .. versionchanged:: 3.4.0
  485. Prior to phpMyAdmin 3.4.0 this was called Linked Tables Infrastructure, but
  486. the name was changed due to the extended scope of the storage.
  487. For a whole set of additional features (:ref:`bookmarks`, comments, :term:`SQL`-history,
  488. tracking mechanism, :term:`PDF`-generation, :ref:`transformations`, :ref:`relations`
  489. etc.) you need to create a set of special tables. Those tables can be located
  490. in your own database, or in a central database for a multi-user installation
  491. (this database would then be accessed by the controluser, so no other user
  492. should have rights to it).
  493. .. _zeroconf:
  494. Zero configuration
  495. ------------------
  496. In many cases, this database structure can be automatically created and
  497. configured. This is called “Zero Configuration” mode and can be particularly
  498. useful in shared hosting situations. “Zeroconf” mode is on by default, to
  499. disable set :config:option:`$cfg['ZeroConf']` to false.
  500. The following three scenarios are covered by the Zero Configuration mode:
  501. * When entering a database where the configuration storage tables are not
  502. present, phpMyAdmin offers to create them from the Operations tab.
  503. * When entering a database where the tables do already exist, the software
  504. automatically detects this and begins using them. This is the most common
  505. situation; after the tables are initially created automatically they are
  506. continually used without disturbing the user; this is also most useful on
  507. shared hosting where the user is not able to edit :file:`config.inc.php` and
  508. usually the user only has access to one database.
  509. * When having access to multiple databases, if the user first enters the
  510. database containing the configuration storage tables then switches to
  511. another database,
  512. phpMyAdmin continues to use the tables from the first database; the user is
  513. not prompted to create more tables in the new database.
  514. Manual configuration
  515. --------------------
  516. Please look at your ``./sql/`` directory, where you should find a
  517. file called *create\_tables.sql*. (If you are using a Windows server,
  518. pay special attention to :ref:`faq1_23`).
  519. If you already had this infrastructure and:
  520. * upgraded to MySQL 4.1.2 or newer, please use
  521. :file:`sql/upgrade_tables_mysql_4_1_2+.sql`.
  522. * upgraded to phpMyAdmin 4.3.0 or newer from 2.5.0 or newer (<= 4.2.x),
  523. please use :file:`sql/upgrade_column_info_4_3_0+.sql`.
  524. * upgraded to phpMyAdmin 4.7.0 or newer from 4.3.0 or newer,
  525. please use :file:`sql/upgrade_tables_4_7_0+.sql`.
  526. and then create new tables by importing :file:`sql/create_tables.sql`.
  527. You can use your phpMyAdmin to create the tables for you. Please be
  528. aware that you may need special (administrator) privileges to create
  529. the database and tables, and that the script may need some tuning,
  530. depending on the database name.
  531. After having imported the :file:`sql/create_tables.sql` file, you
  532. should specify the table names in your :file:`config.inc.php` file. The
  533. directives used for that can be found in the :ref:`config`.
  534. You will also need to have a controluser
  535. (:config:option:`$cfg['Servers'][$i]['controluser']` and
  536. :config:option:`$cfg['Servers'][$i]['controlpass']` settings)
  537. with the proper rights to those tables. For example you can create it
  538. using following statement:
  539. .. code-block:: mysql
  540. GRANT SELECT, INSERT, UPDATE, DELETE ON <pma_db>.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass';
  541. .. _upgrading:
  542. Upgrading from an older version
  543. +++++++++++++++++++++++++++++++
  544. .. warning::
  545. **Never** extract the new version over an existing installation of
  546. phpMyAdmin, always first remove the old files keeping just the
  547. configuration.
  548. This way, you will not leave any old or outdated files in the directory,
  549. which can have severe security implications or can cause various breakages.
  550. Simply copy :file:`config.inc.php` from your previous installation into
  551. the newly unpacked one. Configuration files from old versions may
  552. require some tweaking as some options have been changed or removed.
  553. For compatibility with PHP 5.3 and later, remove a
  554. ``set_magic_quotes_runtime(0);`` statement that you might find near
  555. the end of your configuration file.
  556. You should **not** copy :file:`libraries/config.default.php` over
  557. :file:`config.inc.php` because the default configuration file is version-
  558. specific.
  559. The complete upgrade can be performed in a few simple steps:
  560. 1. Download the latest phpMyAdmin version from <https://www.phpmyadmin.net/downloads/>.
  561. 2. Rename existing phpMyAdmin folder (for example to ``phpmyadmin-old``).
  562. 3. Unpack freshly downloaded phpMyAdmin to the desired location (for example ``phpmyadmin``).
  563. 4. Copy :file:`config.inc.php`` from old location (``phpmyadmin-old``) to the new one (``phpmyadmin``).
  564. 5. Test that everything works properly.
  565. 6. Remove backup of a previous version (``phpmyadmin-old``).
  566. If you have upgraded your MySQL server from a version previous to 4.1.2 to
  567. version 5.x or newer and if you use the phpMyAdmin configuration storage, you
  568. should run the :term:`SQL` script found in
  569. :file:`sql/upgrade_tables_mysql_4_1_2+.sql`.
  570. If you have upgraded your phpMyAdmin to 4.3.0 or newer from 2.5.0 or
  571. newer (<= 4.2.x) and if you use the phpMyAdmin configuration storage, you
  572. should run the :term:`SQL` script found in
  573. :file:`sql/upgrade_column_info_4_3_0+.sql`.
  574. Do not forget to clear the browser cache and to empty the old session by
  575. logging out and logging in again.
  576. .. index:: Authentication mode
  577. .. _authentication_modes:
  578. Using authentication modes
  579. ++++++++++++++++++++++++++
  580. :term:`HTTP` and cookie authentication modes are recommended in a **multi-user
  581. environment** where you want to give users access to their own database and
  582. don't want them to play around with others. Nevertheless, be aware that MS
  583. Internet Explorer seems to be really buggy about cookies, at least till version
  584. 6. Even in a **single-user environment**, you might prefer to use :term:`HTTP`
  585. or cookie mode so that your user/password pair are not in clear in the
  586. configuration file.
  587. :term:`HTTP` and cookie authentication
  588. modes are more secure: the MySQL login information does not need to be
  589. set in the phpMyAdmin configuration file (except possibly for the
  590. :config:option:`$cfg['Servers'][$i]['controluser']`).
  591. However, keep in mind that the password travels in plain text unless
  592. you are using the HTTPS protocol. In cookie mode, the password is
  593. stored, encrypted with the AES algorithm, in a temporary cookie.
  594. Then each of the *true* users should be granted a set of privileges
  595. on a set of particular databases. Normally you shouldn't give global
  596. privileges to an ordinary user unless you understand the impact of those
  597. privileges (for example, you are creating a superuser).
  598. For example, to grant the user *real_user* with all privileges on
  599. the database *user_base*:
  600. .. code-block:: mysql
  601. GRANT ALL PRIVILEGES ON user_base.* TO 'real_user'@localhost IDENTIFIED BY 'real_password';
  602. What the user may now do is controlled entirely by the MySQL user management
  603. system. With HTTP or cookie authentication mode, you don't need to fill the
  604. user/password fields inside the :config:option:`$cfg['Servers']`.
  605. .. seealso::
  606. :ref:`faq1_32`,
  607. :ref:`faq1_35`,
  608. :ref:`faq4_1`,
  609. :ref:`faq4_2`,
  610. :ref:`faq4_3`
  611. .. index:: pair: HTTP; Authentication mode
  612. .. _auth_http:
  613. HTTP authentication mode
  614. ------------------------
  615. * Uses :term:`HTTP` Basic authentication
  616. method and allows you to log in as any valid MySQL user.
  617. * Is supported with most PHP configurations. For :term:`IIS` (:term:`ISAPI`)
  618. support using :term:`CGI` PHP see :ref:`faq1_32`, for using with Apache
  619. :term:`CGI` see :ref:`faq1_35`.
  620. * When PHP is running under Apache's :term:`mod_proxy_fcgi` (e.g. with PHP-FPM),
  621. ``Authorization`` headers are not passed to the underlying FCGI application,
  622. such that your credentials will not reach the application. In this case, you can
  623. add the following configuration directive:
  624. .. code-block:: apache
  625. SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
  626. * See also :ref:`faq4_4` about not using the :term:`.htaccess` mechanism along with
  627. ':term:`HTTP`' authentication mode.
  628. .. note::
  629. There is no way to do proper logout in HTTP authentication, most browsers
  630. will remember credentials until there is no different successful
  631. authentication. Because of this, this method has a limitation that you can not
  632. login with the same user after logout.
  633. .. index:: pair: Cookie; Authentication mode
  634. .. _cookie:
  635. Cookie authentication mode
  636. --------------------------
  637. * Username and password are stored in cookies during the session and password
  638. is deleted when it ends.
  639. * With this mode, the user can truly log out of phpMyAdmin and log
  640. back in with the same username (this is not possible with :ref:`auth_http`).
  641. * If you want to allow users to enter any hostname to connect (rather than only
  642. servers that are configured in :file:`config.inc.php`),
  643. see the :config:option:`$cfg['AllowArbitraryServer']` directive.
  644. * As mentioned in the :ref:`require` section, having the ``openssl`` extension
  645. will speed up access considerably, but is not required.
  646. .. index:: pair: Signon; Authentication mode
  647. .. _auth_signon:
  648. Signon authentication mode
  649. --------------------------
  650. * This mode is a convenient way of using credentials from another
  651. application to authenticate to phpMyAdmin to implement a single signon
  652. solution.
  653. * The other application has to store login information into session
  654. data (see :config:option:`$cfg['Servers'][$i]['SignonSession']` and
  655. :config:option:`$cfg['Servers'][$i]['SignonCookieParams']`) or you
  656. need to implement script to return the credentials (see
  657. :config:option:`$cfg['Servers'][$i]['SignonScript']`).
  658. * When no credentials are available, the user is being redirected to
  659. :config:option:`$cfg['Servers'][$i]['SignonURL']`, where you should handle
  660. the login process.
  661. The very basic example of saving credentials in a session is available as
  662. :file:`examples/signon.php`:
  663. .. literalinclude:: ../examples/signon.php
  664. :language: php
  665. Alternatively, you can also use this way to integrate with OpenID as shown
  666. in :file:`examples/openid.php`:
  667. .. literalinclude:: ../examples/openid.php
  668. :language: php
  669. If you intend to pass the credentials using some other means than, you have to
  670. implement wrapper in PHP to get that data and set it to
  671. :config:option:`$cfg['Servers'][$i]['SignonScript']`. There is a very minimal example
  672. in :file:`examples/signon-script.php`:
  673. .. literalinclude:: ../examples/signon-script.php
  674. :language: php
  675. .. seealso::
  676. :config:option:`$cfg['Servers'][$i]['auth_type']`,
  677. :config:option:`$cfg['Servers'][$i]['SignonSession']`,
  678. :config:option:`$cfg['Servers'][$i]['SignonCookieParams']`,
  679. :config:option:`$cfg['Servers'][$i]['SignonScript']`,
  680. :config:option:`$cfg['Servers'][$i]['SignonURL']`,
  681. :ref:`example-signon`
  682. .. index:: pair: Config; Authentication mode
  683. .. _auth_config:
  684. Config authentication mode
  685. --------------------------
  686. * This mode is sometimes the less secure one because it requires you to fill the
  687. :config:option:`$cfg['Servers'][$i]['user']` and
  688. :config:option:`$cfg['Servers'][$i]['password']`
  689. fields (and as a result, anyone who can read your :file:`config.inc.php`
  690. can discover your username and password).
  691. * In the :ref:`faqmultiuser` section, there is an entry explaining how
  692. to protect your configuration file.
  693. * For additional security in this mode, you may wish to consider the
  694. Host authentication :config:option:`$cfg['Servers'][$i]['AllowDeny']['order']`
  695. and :config:option:`$cfg['Servers'][$i]['AllowDeny']['rules']` configuration directives.
  696. * Unlike cookie and http, does not require a user to log in when first
  697. loading the phpMyAdmin site. This is by design but could allow any
  698. user to access your installation. Use of some restriction method is
  699. suggested, perhaps a :term:`.htaccess` file with the HTTP-AUTH directive or disallowing
  700. incoming HTTP requests at one’s router or firewall will suffice (both
  701. of which are beyond the scope of this manual but easily searchable
  702. with Google).
  703. .. _securing:
  704. Securing your phpMyAdmin installation
  705. +++++++++++++++++++++++++++++++++++++
  706. The phpMyAdmin team tries hard to make the application secure, however there
  707. are always ways to make your installation more secure:
  708. * Follow our `Security announcements <https://www.phpmyadmin.net/security/>`_ and upgrade
  709. phpMyAdmin whenever new vulnerability is published.
  710. * Serve phpMyAdmin on HTTPS only. Preferably, you should use HSTS as well, so that
  711. you're protected from protocol downgrade attacks.
  712. * Ensure your PHP setup follows recommendations for production sites, for example
  713. `display_errors <https://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors>`_
  714. should be disabled.
  715. * Remove the ``test`` directory from phpMyAdmin, unless you are developing and need a test suite.
  716. * Remove the ``setup`` directory from phpMyAdmin, you will probably not
  717. use it after the initial setup.
  718. * Properly choose an authentication method - :ref:`cookie`
  719. is probably the best choice for shared hosting.
  720. * Deny access to auxiliary files in :file:`./libraries/` or
  721. :file:`./templates/` subfolders in your webserver configuration.
  722. Such configuration prevents from possible path exposure and cross side
  723. scripting vulnerabilities that might happen to be found in that code. For the
  724. Apache webserver, this is often accomplished with a :term:`.htaccess` file in
  725. those directories.
  726. * Deny access to temporary files, see :config:option:`$cfg['TempDir']` (if that
  727. is placed inside your web root, see also :ref:`web-dirs`.
  728. * It is generally a good idea to protect a public phpMyAdmin installation
  729. against access by robots as they usually can not do anything good there. You
  730. can do this using ``robots.txt`` file in the root of your webserver or limit
  731. access by web server configuration, see :ref:`faq1_42`.
  732. * In case you don't want all MySQL users to be able to access
  733. phpMyAdmin, you can use :config:option:`$cfg['Servers'][$i]['AllowDeny']['rules']` to limit them
  734. or :config:option:`$cfg['Servers'][$i]['AllowRoot']` to deny root user access.
  735. * Enable :ref:`2fa` for your account.
  736. * Consider hiding phpMyAdmin behind an authentication proxy, so that
  737. users need to authenticate prior to providing MySQL credentials
  738. to phpMyAdmin. You can achieve this by configuring your web server to request
  739. HTTP authentication. For example in Apache this can be done with:
  740. .. code-block:: apache
  741. AuthType Basic
  742. AuthName "Restricted Access"
  743. AuthUserFile /usr/share/phpmyadmin/passwd
  744. Require valid-user
  745. Once you have changed the configuration, you need to create a list of users which
  746. can authenticate. This can be done using the :program:`htpasswd` utility:
  747. .. code-block:: sh
  748. htpasswd -c /usr/share/phpmyadmin/passwd username
  749. * If you are afraid of automated attacks, enabling Captcha by
  750. :config:option:`$cfg['CaptchaLoginPublicKey']` and
  751. :config:option:`$cfg['CaptchaLoginPrivateKey']` might be an option.
  752. * Failed login attemps are logged to syslog (if available, see
  753. :config:option:`$cfg['AuthLog']`). This can allow using a tool such as
  754. fail2ban to block brute-force attempts. Note that the log file used by syslog
  755. is not the same as the Apache error or access log files.
  756. * In case you're running phpMyAdmin together with other PHP applications, it is
  757. generally advised to use separate session storage for phpMyAdmin to avoid
  758. possible session-based attacks against it. You can use
  759. :config:option:`$cfg['SessionSavePath']` to achieve this.
  760. .. _ssl:
  761. Using SSL for connection to database server
  762. +++++++++++++++++++++++++++++++++++++++++++
  763. It is recommended to use SSL when connecting to remote database server. There
  764. are several configuration options involved in the SSL setup:
  765. :config:option:`$cfg['Servers'][$i]['ssl']`
  766. Defines whether to use SSL at all. If you enable only this, the connection
  767. will be encrypted, but there is not authentication of the connection - you
  768. can not verify that you are talking to the right server.
  769. :config:option:`$cfg['Servers'][$i]['ssl_key']` and :config:option:`$cfg['Servers'][$i]['ssl_cert']`
  770. This is used for authentication of client to the server.
  771. :config:option:`$cfg['Servers'][$i]['ssl_ca']` and :config:option:`$cfg['Servers'][$i]['ssl_ca_path']`
  772. The certificate authorities you trust for server certificates.
  773. This is used to ensure that you are talking to a trusted server.
  774. :config:option:`$cfg['Servers'][$i]['ssl_verify']`
  775. This configuration disables server certificate verification. Use with
  776. caution.
  777. .. seealso::
  778. :ref:`example-google-ssl`,
  779. :config:option:`$cfg['Servers'][$i]['ssl']`,
  780. :config:option:`$cfg['Servers'][$i]['ssl_key']`,
  781. :config:option:`$cfg['Servers'][$i]['ssl_cert']`,
  782. :config:option:`$cfg['Servers'][$i]['ssl_ca']`,
  783. :config:option:`$cfg['Servers'][$i]['ssl_ca_path']`,
  784. :config:option:`$cfg['Servers'][$i]['ssl_ciphers']`,
  785. :config:option:`$cfg['Servers'][$i]['ssl_verify']`
  786. Known issues
  787. ++++++++++++
  788. Users with column-specific privileges are unable to "Browse"
  789. ------------------------------------------------------------
  790. If a user has only column-specific privileges on some (but not all) columns in a table, "Browse"
  791. will fail with an error message.
  792. As a workaround, a bookmarked query with the same name as the table can be created, this will
  793. run when using the "Browse" link instead. `Issue 11922 <https://github.com/phpmyadmin/phpmyadmin/issues/11922>`_.
  794. Trouble logging back in after logging out using 'http' authentication
  795. ----------------------------------------------------------------------
  796. When using the 'http' ``auth_type``, it can be impossible to log back in (when the logout comes
  797. manually or after a period of inactivity). `Issue 11898 <https://github.com/phpmyadmin/phpmyadmin/issues/11898>`_.
  798. .. _Composer tool: https://getcomposer.org/
  799. .. _Packagist: https://packagist.org/
  800. .. _Docker image: https://hub.docker.com/r/phpmyadmin/phpmyadmin/