4

I recently configured two servers. The first to use Apache and phpMyAdmin. On the other server I have a maria-DB server correctly configured.

phpMyAdmin it's reading the config file, but I can't connect to MariaDB server and PMA is throwing

#2002 Cannot log in to the MySQL server

phpMyAdmin Error

Using mysql command to connect from the web server to the database server and using the same user/password, I can successfully connect to the database server.

No errors in mysql, all the ports for mysql are opened in the firewall, no php errors. I didn't have any luck finding the problem.

Edit:

Accesing the Server via Shell

[root@pw000i rafael]# mysql -h [IP ADRESS TO THE REMOTE SERVER]  -u rafael -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.36-MariaDB-log MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

config.inc.php from PhpMyAdmin

<?php
/**
 * phpMyAdmin configuration file, you can use it as base for the manual
 * configuration. For easier setup you can use "setup/".
 *
 * All directives are explained in Documentation.html and on phpMyAdmin
 * wiki <http://wiki.phpmyadmin.net>.
 */

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = 'MY SECRET PASSPHRASE IS HIDDEN'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

/**
 * Server(s) configuration
 */
$i = 0;

// The $cfg['Servers'] array starts with $cfg['Servers'][1].  Do not use
// $cfg['Servers'][0]. You can disable a server config entry by setting host
// to ''. If you want more than one server, just copy following section
// (including $i incrementation) serveral times. There is no need to define
// full server array, just define values you need to change.
$i++;
$cfg['Servers'][$i]['host']          = '10.XX.X.XXX'; // MySQL hostname or IP ad                                                                  dress
$cfg['Servers'][$i]['port']          = '';          // MySQL port - leave blank                                                                   for default port
$cfg['Servers'][$i]['socket']        = '';          // Path to the socket - leav                                                                  e blank for default socket
$cfg['Servers'][$i]['connect_type']  = 'tcp';       // How to connect to MySQL s                                                                  erver ('tcp' or 'socket')
$cfg['Servers'][$i]['extension']     = 'mysqli';    // The php MySQL extension t                                                                  o use ('mysql' or 'mysqli')
$cfg['Servers'][$i]['compress']      = FALSE;       // Use compressed protocol f                                                                  or the MySQL connection
                                                    // (requires PHP >= 4.3.0)
$cfg['Servers'][$i]['controluser']   = '';          // MySQL control user settin                                                                  gs
                                                    // (this user must have read                                                                  -only
$cfg['Servers'][$i]['controlpass']   = '';          // access to the "mysql/user                                                                  "
                                                    // and "mysql/db" tables).
                                                    // The controluser is also
                                                    // used for all relational
                                                    // features (pmadb)
$cfg['Servers'][$i]['auth_type']     = 'cookie';      // Authentication method (                                                                  config, http or cookie based)?
$cfg['Servers'][$i]['user']          = 'rafael';          // MySQL user
$cfg['Servers'][$i]['password']      = '';          // MySQL password (only need                                                                  ed
                                                    // with 'config' auth_type)
$cfg['Servers'][$i]['only_db']       = '';          // If set to a db-name, only
                                                    // this db is displayed in l                                                                  eft frame
                                                    // It may also be an array o                                                                  f db-names, where sorting order is relevant.
$cfg['Servers'][$i]['hide_db']       = '';          // Database name to be hidde                                                                  n from listings
$cfg['Servers'][$i]['verbose']       = 'new-db-mariaDB';          // Verbose nam                                                                  e for this host - leave blank to show the hostname

$cfg['Servers'][$i]['pmadb']         = '';          // Database used for Relatio                                                                  n, Bookmark and PDF Features
                                                    // (see scripts/create_table                                                                  s.sql)
                                                    //   - leave blank for no su                                                                  pport
                                                    //     DEFAULT: 'phpmyadmin'
$cfg['Servers'][$i]['bookmarktable'] = '';          // Bookmark table
                                                    //   - leave blank for no bo                                                                  okmark support
                                                    //     DEFAULT: 'pma_bookmar                                                                  k'
$cfg['Servers'][$i]['relation']      = '';          // table to describe the rel                                                                  ation between links (see doc)
                                                    //   - leave blank for no re                                                                  lation-links support
                                                    //     DEFAULT: 'pma_relatio                                                                  n'
$cfg['Servers'][$i]['table_info']    = '';          // table to describe the dis                                                                  play fields
                                                    //   - leave blank for no di                                                                  splay fields support
                                                    //     DEFAULT: 'pma_table_i                                                                  nfo'
$cfg['Servers'][$i]['table_coords']  = '';          // table to describe the tab                                                                  les position for the PDF schema
                                                    //   - leave blank for no PD                                                                  F schema support
                                                    //     DEFAULT: 'pma_table_c                                                                  oords'
$cfg['Servers'][$i]['pdf_pages']     = '';          // table to describe pages o                                                                  f relationpdf
                                                    //   - leave blank if you do                                                                  n't want to use this
                                                    //     DEFAULT: 'pma_pdf_pag                                                                  es'
$cfg['Servers'][$i]['column_info']   = '';          // table to store column inf                                                                  ormation
                                                    //   - leave blank for no co                                                                  lumn comments/mime types
                                                    //     DEFAULT: 'pma_column_                                                                  info'
$cfg['Servers'][$i]['history']       = '';          // table to store SQL histor                                                                  y
                                                    //   - leave blank for no SQ                                                                  L query history
                                                    //     DEFAULT: 'pma_history                                                                  '
$cfg['Servers'][$i]['verbose_check'] = TRUE;        // set to FALSE if you know                                                                   that your pma_* tables
                                                    // are up to date. This prev                                                                  ents compatibility
                                                    // checks and thereby increa                                                                  ses performance.
$cfg['Servers'][$i]['AllowRoot']     = TRUE;        // whether to allow root log                                                                  in
$cfg['Servers'][$i]['AllowDeny']['order']           // Host authentication order                                                                  , leave blank to not use
                                     = '';
$cfg['Servers'][$i]['AllowDeny']['rules']           // Host authentication rules                                                                  , leave blank for defaults
                                     = array();
$cfg['Servers'][$i]['AllowNoPassword']              // Allow logins without a pa                                                                  ssword. Do not change the FALSE
                                     = FALSE;       // default unless you're run                                                                  ning a passwordless MySQL server
$cfg['Servers'][$i]['designer_coords']              // Leave blank (default) for                                                                   no Designer support, otherwise
                                     = '';          // set to suggested 'pma_des                                                                  igner_coords' if really needed
$cfg['Servers'][$i]['bs_garbage_threshold']         // Blobstreaming: Recommente                                                                  d default value from upstream
                                     = 50;          //   DEFAULT: '50'
$cfg['Servers'][$i]['bs_repository_threshold']      // Blobstreaming: Recommente                                                                  d default value from upstream
                                     = '32M';       //   DEFAULT: '32M'
$cfg['Servers'][$i]['bs_temp_blob_timeout']         // Blobstreaming: Recommente                                                                  d default value from upstream
                                     = 600;         //   DEFAULT: '600'
$cfg['Servers'][$i]['bs_temp_log_threshold']        // Blobstreaming: Recommente                                                                  d default value from upstream
                                     = '32M';       //   DEFAULT: '32M'
/*
 * End of servers configuration
 */

/*
 * Directories for saving/loading files from server
 */
$cfg['UploadDir'] = '/var/lib/phpMyAdmin/upload';
$cfg['SaveDir']   = '/var/lib/phpMyAdmin/save';

/*
 * Disable the default warning that is displayed on the DB Details Structure
 * page if any of the required Tables for the relation features is not found
 */
$cfg['PmaNoRelation_DisableWarning'] = TRUE;
?>

I'm using Fedora 20 on both servers. Any Ideas?

9
  • 2
    Please post the entire error message. Commented Mar 22, 2014 at 1:01
  • Can you post here your complete config.inc.php and the full command you use to connect via the mysql command? (Please obscure any sensitive information such as passwords).
    – ibennetch
    Commented Mar 23, 2014 at 3:59
  • @ibennetch i added more details, i hope this helps
    – Rafael
    Commented Mar 23, 2014 at 17:30
  • Oh, that's stupid. phpMyAdmin doesn't even show the entire error message! Commented Mar 23, 2014 at 17:42
  • @MichaelHampton if you know a way to capture the full error message i'm open to suggestion
    – Rafael
    Commented Mar 23, 2014 at 17:44

1 Answer 1

5

Solved, the guilty was SELinux.

[root@pw000i rafael]# getsebool -a | grep httpd
httpd_anon_write --> off
httpd_builtin_scripting --> on
httpd_can_check_spam --> off
httpd_can_connect_ftp --> off
httpd_can_connect_ldap --> off
httpd_can_connect_mythtv --> off
httpd_can_connect_zabbix --> off
httpd_can_network_connect --> off
httpd_can_network_connect_cobbler --> off
httpd_can_network_connect_db --> off     <----- THIS SETTING IT'S THE GUILTY 
httpd_can_network_memcache --> off
httpd_can_network_relay --> off
httpd_can_sendmail --> off
httpd_dbus_avahi --> off
httpd_dontaudit_search_dirs --> off
httpd_enable_cgi --> on
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> off
httpd_execmem --> off
httpd_graceful_shutdown --> on
httpd_manage_ipa --> off
httpd_mod_auth_ntlm_winbind --> off
httpd_mod_auth_pam --> off
httpd_read_user_content --> off
httpd_run_stickshift --> off
httpd_serve_cobbler_files --> off
httpd_setrlimit --> off
httpd_ssi_exec --> off
httpd_sys_script_anon_write --> off
httpd_tmp_exec --> off
httpd_tty_comm --> off
httpd_unified --> off
httpd_use_cifs --> off
httpd_use_fusefs --> off
httpd_use_gpg --> off
httpd_use_nfs --> off
httpd_use_openstack --> off
httpd_use_sasl --> off
httpd_verify_dns --> off

the solution it's simple

[root@pw000i rafael]# setsebool -P httpd_can_network_connect_db on

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .