setup.txt 41 KB

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