Warning: Mysqli_Connect(): (Hy000/1049): Unknown Database in MAC Terminal Only

Warning: mysqli_connect(): (HY000/1049): Unknown database in mac terminal only

Is your PHP environment the same as your browsers PHP? command line php.ini can differ from, for example, your XAMP or other installed webserver

I would recommend checking this first

for me this did the trick

edit your .bash_profile file like

export PATH=/Applications/MAMP/bin/php/php7.1.1/bin:$PATH

edit the path to your PHP bin from your XAMP

Laravel SQLSTATE[HY000] [1049] Unknown database 'previous_db_name'

It clearly mentions that there's no such database named previous_db_name.

From what it seems the database.php file is not where the variable is from.

Check the .env file in your Laravel installation folder to see if that's the database name that you have wrongly specified.

php mysqli_connect: authentication method unknown to the client [caching_sha2_password]

As of PHP 7.4, this is no longer an issue. Support for caching_sha2 authentication method has been added to mysqlnd.


Currently, PHP mysqli extension do not support new caching_sha2 authentication feature.
You have to wait until they release an update.

Check related post from MySQL developers: https://mysqlserverteam.com/upgrading-to-mysql-8-0-default-authentication-plugin-considerations/

They didn't mention PDO, maybe you should try to connect with PDO.

PHP Warning: mysqli_connect(): (HY000/2002): Connection refused

In case anyone else comes by this issue, the default port on MAMP for mysql is 8889, but the port that php expects to use for mysql is 3306. So you need to open MAMP, go to preferences, and change the MAMP mysql port to 3306, then restart the mysql server. Now the connection should be successful with host=localhost, user=root, pass=root.



Related Topics



Leave a reply



Submit