I'm running MacOS Sierra and I'm trying to install locally Sylius. Although I (finally) managed to get it installed, I'm still facing connection error with the DB.
Here is the error I'm getting:
Error
Do you have any idea of where might this come from?
Thanks!
Andrea
Ensure that the MySQL server is running. If using MAMP, check MAMP and ensure that MySQL is started. If not using MAMP, try this:
$ mysql.server start
See if you can connect through the console now. If so, you should be able to connect through Sylius.
Related
I am new to PHP and Laravel.
I installed Laravel and Composer , created new project and it is working fine.
Now when i tried to migrate a database using this command php artisan migrate i got errors, i wonder is it something related to not installing Xampp ? i am running Mac OS
The errors i got is
1 PDOException::("SQLSTATE[HY000] [2002] Connection refused")
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
2 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=app", "root", "", [])
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
Xampp has nothing to do with Laravel itself. Xampp is a set of tools that is usually used together to deliver websites. Xampp just makes it easier (supposedly) to install those set for you. Rather than having to install and setup all yourself.
Today people tend to avoid such sets in favour for tools like Vagrant or Docker.
Laravel even provides its own Vagrant setup called Homestead.
See ie. in Laravel 5.5 docs: https://laravel.com/docs/5.5/homestead
If you don't want to use Homestead but build your own server environment there's also tools to make this easier for you.
For example there is http://www.puphpet.com for PHP + Vagrant and https://phpdocker.io/ for PHP + Docker.
Xampp is not required but a php server like apache or nginx is required also in order to use mysql you should have mysql installed you get this error
PDOException::("SQLSTATE[HY000] [2002] Connection refused")
/app/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:68
because the mysql service is turned off so I think you open Xampp control Panel and you start mysql in order for it to work and this is why you have asked if Xampp is required am I right !!!
Actually to prove that Xampp has nothing to do with Laravel you can start the mysql server from command line I will give you example in windows OS.
if you have xampp installed on C:/ Driver lets say then try cd(change directory) into this path in your command line
cd c:/xampp/mysql/bin
start mysqld.exe // this will start the mysql service for you
now you can navigate to your Laravel app and try to migrate this time you won't get connection refused error and that is because you have started the Mysql server from command line.
I think this proves that Xampp has nothing to do with Laravel.
Hope this was helpful, good luck.
Mac OS comes with PHP built into it. You should be able to use php -v to see what version. Use php -S localhost:xxxx to output the local directory to a local address.
For example, to run laravel locally, open the terminal cmd+spacebar, type terminal, open it, then use change to the path where your laravel project is.
Type php -S localhost:3000 and it should give you a confirmation in the terminal. Now open a browser and go to localhost:3000 and it should show your project.
As a young developer, my first task is to migrate a website on another server. I was thinking it will take me less than 2 days but no.
The website was made with PHP 5.6 with the CMS Joomla! 1.5. I've migrate the sources, but when I try the page, I got the message:
Database Error: Unable to connect to the database:Could not connect to MySQL
I've tried multiples manipulations:
I have installed Plesk Onyx for do the migration, but same message
I have tried with Plesk 12.5, but same,
I have tried by copiing sources manually on the serv, it didn't work too
I have check my LAMP server, the php test is okey, the mysql (MariaDB) too, and Apache2 test is okey.
I have already edit the configuration.php file, but it's the same problem.
I have tested on another OS for my server (last one was Debian), now I have installed centos 7, but I don't change anything.
Don't know what's wrong with my migration, if somebody have and idea, I'm listening
The answer is in the error message Joomla gave you. The details you've set for accessing the database are wrong.
Did you create a MySQL database for your new site? Did you import the database from the old site to the new server?
I'm using a Macbook Pro. I tried to setup for PHP. The server I'm using is MAMP. After I start MAMP, I can run localhost/phpmyadmin and MySQLWorkbench. But when I try to run mysql through Terminal, I can't connect to my database. I had to disconnect MAMP in order to access my database through Terminal. Then when I restart MAMP, it just connect to Apache Server instead of both Apache and MySQL Server. I figure the port is not 3306 when I run mysql through Terminal. I wonder if I could change the port to 3306 so I can make change to the database I make in the terminal with phpmyadmin. I searched the Internet but couldn't find a solution.
Just now, I couldn't run mysql in terminal. I'm so frustrated. Can somebody help?
Update: I just found out Macbook comes with built-in Apache and Mysql Server. I followed the instruction from below website to set it up and it works. Hope this can help those who has the same problem.
https://coolestguidesontheplanet.com/get-apache-mysql-php-and-phpmyadmin-working-on-macos-sierra/
Maybe... I had the same problem with 2 versions of php (2 differents locations on disk). phpinfo() saw a version, the terminal saw another. The solution: change the $ PATH environment variable.
Hope this helps...
In the MAMP menu bar>> Tools - I am seeing this:
phpMyAdmin(needs PHP5.5x to 7.0x)
SQLite Manager (needs PHP5.2.x or 5.3.x)
I have 8 sites on one shared database developed locally using MAMP. Never had a problem in the past. I cannot access any of the sites via localhost. - the last site I worked on required a newer version of PHP and I added V7.1.1 - the prior sites are run on earlier PHP versions, built full site using php 7.1.1 locally no problem. - That said, currently
none of the sites will open via localhost.
The only thing I can think of is that I may have upgraded to OS Sierra and maybe that threw off a file? I called Apple they recommend not touching the Apache settings. I reinstalled Mamp, no change.
OS Sierra 10.12.3
MAMP V.4.1.1
PHP V. 7.1.1
I can connect to the internet, and my firewall is off.
I checked my host file - everything is there that should be with the exception of : "sudo killall -HUP mDNSResponder" which I read in an earlier thread - do I need this?
localhost connection message:
"Unable to connect
Firefox can’t establish a connection to the server at localhost:8888."
I thought that by downloading the lastest version of MAMP I would be recieving the latest package of software such as apache,mysqyl and phpMyAdmin?
I humbly ask for any insight and thank you in advance!
I'm having this same issue and just found this on google:
After you run the servers on MAMP/MAMP PRO
TRY THIS:
localhost:8888/phpmyadmin
So I have been trying to get my localhost up on my brand new MacBook Air on OSX El Capitan.
What I have so far is PHP seems to be working correctly, Apache seems to be working correctly also, but mysql is giving me a headache.
I tried to install the stock version of mysql, which doesn't seem to work at all, it started and every time I tried to login to mysql it completely broke and I didn't see any error messages, but I guess it was the same I got for the homebrew installed version.
When I tried Homwbrew brew install mysql it worked correctly.
Then I tried mysql_secure_installation it threw and error: Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Then I tried mysql.server start and I got ... ERROR! The server quit without updating PID file (/usr/local/var/mysql/Szekelys-MacBook-Air.local.pid).
This is my third fresh install for Mac and I have no idea at this point.
I tried permissions, creating the PID file and a lot of other things.
I'm afraid that I've not got a solution for you. I'm in the same boat though. I have exactly the same error, and I've tried installing with brew as well as directly.
Even worse, I've got it working in my iMac, but not my Macbook Pro.
The only difference I can see is the version. I've got
mysql-5.6.26-osx10.8-x86_64
on the iMac, working well.
The one that's not working has:
mysql-5.7.9-osx10.9-x86_64
I'm going to try using the earlier revision, it's the only thing I've not tried yet.
I know this is weird, but I have been experiencing the same problem over and over and coming upon no useful answers like the rest of you, but somehow I happened upon something that DID work on this page
For some reason following the instruction to use mysql.server restart seemed to work. I didn't create any of the suggested launchctl versions either.
I suggest doing a hard cleanup of homebrew brew cleanup --force -s to make sure you get a new download.