CakePHP bake Error: Database connection “Mysql” is missing, or could not be created

让人想犯罪 __ 提交于 2019-12-05 21:22:20

Did you enabled pdo module for cli? I think that you can have different php.ini for cli / web (fpm).

Just to help Ubuntu users out: I had the same error in my ubuntu 13.10 machine with the newest xampp downloaded directly from apachefriends. Try this:

Find the socket that mysqld creates for programs to connect to:

user@host /opt$ find . -name mysql.sock
/opt/lampp/var/mysql/mysql.sock

add it to your cakePHP database configuration file (cakePHP)/app/Config/database.php

'unix_socket' => '/opt/lampp/var/mysql/mysql.sock'

To me, this finally resulted in my cake commands being able to be executed without the "Error: Database connection "Mysql" is missing, or could not be created.".

on apache start if you get a warning that says something along the lines of apache not resolving hostname, using 127.0.1.1.. this may cause problems later with cakephp. solution: sudo nano /etc/apache2/apache2.config , add the line: ServerName localhost

Try to (re)install PHP MySQL support

sudo apt-get install php5-mysql

For me it turned out to be that the server variable $_SERVER['HTTP_HOST'] was not available in the database.php config file so my specific config was not being set correctly when running in a Shell.

$_SERVER['HTTP_HOST'] is not available during Shell execution.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!