Problem with SQLSTATE[HY000] [2002] every time I launch my computer Every time I launch my computer when I type php artisan serve I get these commands..
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `sessions` where `id` = KsL5wVKGbNVEpBvHCDrEr8Q8eoZWA3ja2KGejyvZ limit 1)
I know the solution to my problem which is typing the problem:
sudo chown -R _mysql:mysql /usr/local/var/mysql
sudo mysql.server start
I want it to persist. I don't want this problem to show agoin
By the way, I am using:
Mac, big Sure
Mysql using brew
Laravel 8
@Nakov
I don't find MySQL in system preferences. I have installed it using brew.
@Watheq you should follow the complete post my friend, there is a manual approach through the terminal:
$> cd /Library/LaunchDaemons
$> sudo launchctl load -F com.oracle.oss.mysql.mysqld.plist
anyhow, starting the MySQL deamon is what you should be looking for.
@Nakov
I follow the instruciton but there is No such file or directory
@Watheq When installing MySQL using brew, it provides details at the end of the install on how to launch the service and the deamon. As I said above, launching the MySQL as a deamon is what you should be looking for.
Try this approach: https://stackoverflow.com/a/6378429/1457270 ignore the first part where he removes the installation and check which step you are missing from the "Start from scratch part".
error 2002 for mysql not connected
install xampp
https://www.apachefriends.org/download.html
I think one of these should work for you:
To have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start
Kr
After searching in multiuple places I found the solution:
reset brew permission
then type this command: sudo brew services start mysql
that's it.
Please sign in or create an account to participate in this conversation.