I'm using CakePHP 4 on a Linux Mint cinnamon installation with the LAMPP stack. I have a database with users and all chef hats of PHP are green. The application is also able to fetch data from my database when running in the browser.
I want to bake my users model/controller/views:
bin/cake bake all users
This returns the following error:
Exception: Connection to Mysql could not be established: SQLSTATE[HY000] [2002] No such file or directory
In [/opt/lampp/htdocs/tgi-flydays-4/vendor/cakephp/cakephp/src/Database/Driver.php, line 107]
It looks like connecting to the database via PDO is not working:
99 try {
100 $connection = new PDO(
101 $dsn,
102 $config['username'] ?: null,
103 $config['password'] ?: null,
104 $config['flags']
105 );
106 } catch (PDOException $e) {
107 throw new MissingConnectionException(
108 [
109 'driver' => App::shortName(static::class, 'Database/Driver'),
110 'reason' => $e->getMessage(),
111 ],
112 null,
113 $e
114 );
115 }
I have the database connection details correctly filled in in app_local.php
(as said: running the application in the browser works fine with the database).
I installed php7.4_pdo_mysql
and php7.4-mysql
, running php -m
returns the following:
[PHP Modules]
calendar
Core
ctype
date
exif
FFI
fileinfo
filter
ftp
gettext
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
Zend OPcache
zlib
[Zend Modules]
Zend OPcache
php -i
returns (amongst others):
PDO
PDO support => enabled
PDO drivers => mysql
pdo_mysql
PDO Driver for MySQL => enabled
Client API version => mysqlnd 7.4.5
I also tried the following solutions: