Can't install Piwik

Database setup:
mysql server: localhost
login: root
password: ************
database name: piwik
table prefix: piwik_
adapter: PDO_MYSQL

After entering this info, I get this error:

PDO::__construct(): [2002] Parámetro incorrecto (trying to connect via unix://)
in ‘/home/chaves/.piwik/libs/Zend/Db/Adapter/Pdo/Abstract.php’ at the line 129

#0 Piwik_ErrorHandler(2, PDO::__construct(): [2002] Parámetro incorrecto (trying to connect via unix://), /home/chaves/.piwik/libs/Zend/Db/Adapter/Pdo/Abstract.php, 129, Array ([dsn] => mysql:host=localhost;dbname=piwik;port=3306,[q] => ))
#1 PDO->__construct(mysql:host=localhost;dbname=piwik;port=3306, root, [password], Array ()) called at [/home/chaves/.piwik/libs/Zend/Db/Adapter/Pdo/Abstract.php:129]
#2 Zend_Db_Adapter_Pdo_Abstract->_connect() called at [/home/chaves/.piwik/libs/Zend/Db/Adapter/Pdo/Mysql.php:96]
#3 Zend_Db_Adapter_Pdo_Mysql->connect() called at [/home/chaves/.piwik/core/Db/Pdo/Mysql.php:30]
#4 Piwik_Db_Pdo_Mysql->getConnection() called at [/home/chaves/.piwik/core/Piwik.php:1473]
#5 Piwik::createDatabaseObject(Array ([host] => localhost,[username] => root,[password] => [password],[dbname] => piwik,[tables_prefix] => piwik
,[adapter] => PDO_MYSQL,[port] => 3306)) called at [/home/chaves/.piwik/plugins/Installation/Controller.php:153]
#6 Piwik_Installation_Controller->databaseSetup() called at [/home/chaves/.piwik/plugins/Installation/Installation.php:62]
#7 Piwik_Installation->dispatch(Piwik_Event_Notification Object ([_notificationName] => FrontController.NoConfigurationFile,[_notificationObject] => Exception Object ([] => The configuration file /home/chaves/.piwik/config/config.ini.php has not been found.,[] => ,[] => 0,[] => /home/chaves/.piwik/core/Config.php,[] => 110,[] => Array ([0] => Array ([file] => /home/chaves/.piwik/core/Piwik.php,[line] => 1574,[function] => init,[class] => Piwik_Config,[type] => ->,[args] => Array ()),[1] => Array ([file] => /home/chaves/.piwik/core/FrontController.php,[line] => 202,[function] => createConfigObject,[class] => Piwik,[type] => ::,[args] => Array ()),[2] => Array ([file] => /home/chaves/.piwik/index.php,[line] => 90,[function] => init,[class] => Piwik_FrontController,[type] => ->,[args] => Array ())),[] => ),[_notificationInfo] => Array (),[_notificationState] => 0,[_notificationCount] => 0))
#8 call_user_func_array(Array ([0] => Piwik_Installation Object ([] => Piwik_Installation_Controller),[1] => dispatch), Array ([0] => Piwik_Event_Notification Object ([_notificationName] => FrontController.NoConfigurationFile,[_notificationObject] => Exception Object ([] => The configuration file /home/chaves/.piwik/config/config.ini.php has not been found.,[] => ,[] => 0,[] => /home/chaves/.piwik/core/Config.php,[] => 110,[] => Array ([0] => Array ([file] => /home/chaves/.piwik/core/Piwik.php,[line] => 1574,[function] => init,[class] => Piwik_Config,[type] => ->,[args] => Array ()),[1] => Array ([file] => /home/chaves/.piwik/core/FrontController.php,[line] => 202,[function] => createConfigObject,[class] => Piwik,[type] => ::,[args] => Array ()),[2] => Array ([file] => /home/chaves/.piwik/index.php,[line] => 90,[function] => init,[class] => Piwik_FrontController,[type] => ->,[args] => Array ())),[] => ),[_notificationInfo] => Array (),[_notificationState] => 0,[_notificationCount] => 0))) called at [/home/chaves/.piwik/libs/Event/Dispatcher.php:213]
#9 Event_Dispatcher->addObserver(Array ([0] => Piwik_Installation Object ([] => Piwik_Installation_Controller),[1] => dispatch), FrontController.NoConfigurationFile) called at [/home/chaves/.piwik/core/PluginsManager.php:363]
#10 Piwik_PluginsManager->addPluginObservers(Piwik_Installation Object ([] => Piwik_Installation_Controller)) called at [/home/chaves/.piwik/core/PluginsManager.php:250]
#11 Piwik_PluginsManager->loadPlugins() called at [/home/chaves/.piwik/core/PluginsManager.php:165]
#12 Piwik_PluginsManager->setPluginsToLoad(Array ([0] => CorePluginsAdmin,[1] => CoreAdminHome,[2] => CoreHome,[3] => API,[4] => Widgetize,[5] => LanguagesManager,[6] => Actions,[7] => Dashboard,[8] => Referers,[9] => UserSettings,[10] => UserCountry,[11] => VisitsSummary,[12] => VisitFrequency,[13] => VisitTime,[14] => VisitorInterest,[15] => ExampleAPI,[16] => ExamplePlugin,[17] => ExampleRssWidget,[18] => ExampleFeedburner,[19] => ExampleRssWidget,[20] => Provider,[21] => Feedback,[22] => Login,[23] => UsersManager,[24] => SitesManager,[25] => Installation)) called at [/home/chaves/.piwik/core/FrontController.php:209]
#13 Piwik_FrontController->init() called at [/home/chaves/.piwik/index.php:90]

I have PDO and PDO_MYSQL installed and uncommented in php.ini, and I already gracefully restarted apache.

I get the same error if I replace piwik (database) with another. Same result with a database already created and another not present in the MySQL server.

Your system has to use unix sockets. Ask your sysadmin or hosting provider for the socket path. Replace localhost with the socket path.

Thank you VERY much. It was that. Replacing localhost with 127.0.0.1 (it’s a personal computer) solved the problem.

Hi,

i´ve the same problem. Replacing localhost with 127.0.0.1 did not solve the problem.

PDO::__construct() [pdo.--construct]: [2002] Verbindungsaufbau abgelehnt (trying to connect via tcp://127.0.0.1:3306) 
in '/opt/lampp/htdocs/piwik/libs/Zend/Db/Adapter/Pdo/Abstract.php' at the line 129

I use a server based on SLES10.

edit: php.ini

add:
pdo_mysql.default_socket=/opt/lampp/var/mysql/mysql.sock

and it will work style_emoticons/<#EMO_DIR#>/smile.gif

Try:

pdo_mysql.default_socket=/var/lib/mysql/mysql.sock

For a 2.4 Apache, Piwik 3.0.4 environment, PHP Version 5.6.30