cli > why wp core update says it can’t connect to db, while wp db can do it?

I’ve got a strange problem. The site is running properly, both back and frontend. I just want to update it via wp cli.

It keeps saying Error: No such file or directory and that probably user or password are wrong.
But again, the site is up and running. Also wp db commands will work properly, as well as mysql shell commands. So there’s no connection errors for those programs. Only for wp core. Why?