setup.rst.txt 42 KB

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