php artisan migrate stuck at the beginning of the command - php

[MacOS 10.14.0]
When I create a new project (Laravel new blog)
Then create a table in MySQL (create database blog)
And then update my .env file with the correct userame, password and database.
After creating a project, I will run php artisan migrate
But my terminal stays empty, I can type in my terminal. But it won't do anything.
My storage/logs folder is empty.
I have 2 default migrate files in my database/migrations folder.
php migrate list works
What can it be?

For me it helped just to restart local database.

After a lot of trial and error, I found out that there was something wrong with my MySQL server. I reinstalled MySQL with brew. The latest version of 8 and the latest version of 5.7.*. Both didn't work, because of the following conflict: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2): image not found.
So the whole time, everything in my .env file was correct but my MySQL was broken. I also confirmed that by trying to connect with the app 'Sequel Pro'. And as I thought, it gave me the same conflict.
How I fixed the problem:
Remove all MySQL/MariaDB packages via brew (if you have installed them with brew like me)
Install MySQL Community Server 5.7.* from the official mysql.com website (you can google that file).
Add MySQL to your path export PATH=$PATH:/usr/local/mysql/bin
Go to: System Preferences -> MySQL -> press 'Start MySQL Server'
Change your temporary password with a new one mysqladmin -uroot -p[temporary password] password '[new password]'
Good luck! 👍
EDIT FEBRUARY 26 2019:
I found a problem with changing the random generated password. I was using MySQL Community Server 5.7.25 and the random generated password was: _>9mxWc9a!0.. When I was trying to change the default password with the command above. I was given the following error:
-bash: !0: event not found
If you have the same error as I did or something similar, try the following:
Enter the following command in your terminal: mysqladmin -uroot -p password '[new password]'
When you press enter, it will ask you for a password. Now enter the random generated password that was given to you by the MySql Community Server at installation in a prompt.
It should be working now! 😊

If you're using Docker and getting this error on the host machine, try running the migration in the container cli.

did you connected the laravel project to the database from .env file ?
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=DATABASE_NAME
DB_USERNAME=DATABASE_USERNAME
DB_PASSWORD=DATABASE_PASSWORD

Laravel 5.8 with SQLite.
My problem wasn't with larvel but with DB browser for sqlite. I had to open and close the program for the migrate to finish its process.

Related

Symfony 5 exception Could not find driver

I am making my first app with Symfony and when i setup my database (doesn't matter if it's postgresql or mysql).
I have an error "could not find driver" three time.
One in PDOConnection.php line 38.
Other in Exception.php line 18.
And last one in AbstractMySQLDriver.php line 128.
What i made : i check the php path i also check all the extensions. I check if i fill correctly .env and i check those folders.
PHP version : 7.4
And mysql in docker containers: mysql:5.7.
I really have no idea what to do now
UPDATE:
The problem (for me) was the command php bin/console doctrine:database:create
if you have the same problem try symfony doctrine:database:create
do you use .env file? I have same problem and after a day of disable/enable pdo without any effect, i found that symfony auto add a line to my .env file:
DATABASE_URL=postgresql://db_user:db_password#127.0.0.1:5432/db_name?serverVersion=11&charset=utf8
That make my database url wrong and error not found pdo fire because of postgresql not mysql
Apparently you use Docker, but in your question you mentioned Windows cmd. I suppose, you check PDO extension in your host system, not in container. You need to log into your Docker PHP container and check it there. In Windows Desktop version of Docker there is a button near each container to open command-line interface. You also can use command:
docker exec -it <here goes your container name>
To find out what your container name is, you can use command
docker ps
UPDATE:
To start your project not in Docker, bun on Windows-host itself, you can use very helpful mini-server, provided by Symfony. Run this command inside your project directory:
symfony serve
It will start local server, available by default at address https://127.0.0.1:8000/.
However, keep in mind, that if your project requires database, you will need to have MySQL Server for Windows installed on your host system too.

Edit MySQL table in a Symfony project hosted [SOFTACULOUS]

I'm coding a Symfony project and I should host it on a server that make me install Symfony by Softacolous (I can't use a shell). So, I can't understand how make an edit on the online DB.
Can you help me?
Use cPanel's Remote MySQL to enable access from your local PC and run:
php bin/console doctrine:schema:update --force --env=prod
To update your database from your code.
Also you dont need to install symfony via Softacolous, just upload your local files via ftp

Mysql Server running but Artisan in Laravel project doesn't think so

So, I have recently installed Mysql Server in my Macbook (Mac OS 10.11) and I also installed Mysql Workbench and it works great!
The problem comes when I want to migrate form a Laravel Project using Php Artisan, every time I run the php artisan migrate command it return the following error
[PDOException]
SQLSTATE[HY000] [2002] No such file or directory
I also noticed I have to mysql installations i the following paths:
/usr/local/mysql
/usr/local/mysql-5.7.13-osx10.11-x86_64/ (this is the one I am using)
I placed in the .bash_profile a PATH to the new one (5.7.13) like this:
export PATH=${PATH}:/usr/local/mysql-5.7.13-osx10.11-x86_64/bin/
Do you guys know how can I fix this? Thank you for any help!
Path to the binary doesn't matter, in this case it's looking for a MySQL socket file.
Find your socket file (find / -name mysql.sock)
Ensure this path is set in my.cnf used by your PHP (you can run php -i |grep pdo_mysql.default_socket to see the default path)
As a workaround, you could set a symbolic link from 1 to 2 (eg. ln -s /usr/local/mysql/var/mysql.sock /tmp/mysql.sock) but ideally you want to set a correct path for PDO (or whatever MySQL extension you are using for PHP)

PDOException SQLSTATE[HY000] [2002] No such file or directory when trying to migrate

This question has already been asked multiple times, however I can't seem to get it to work anyway.
I am trying to migrate a migration I just created with laravel to my freshly created database. However, everytime I type in php artisan migrate I'm getting the above error
PDOException SQLSTATE[HY000] [2002] No such file or directory
What I have done is the following:
Create a database and a database user
CREATE DATABASE openletter CHARACTER SET utf8;
CREATE USER 'openletter'#'%' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON openletter.* TO 'openletter'#'%';
Add these configs to the .env
DB_HOST=localhost
DB_DATABASE=openletter
DB_USERNAME=openletter
DB_PASSWORD=secret
Creating the migration
php artisan make:migration create_letters_table --create=letters
Migrating the migration
php artisan migrate
Then, the above listed error came.
What I tried
Restart the MySQL Service: vagrant ssh && sudo service mysqld restart
Reloading Homestead/Vagrant: vagrant reload --provision
Setting the database config in config/database.php
Many people telling others to link the mysql socket, but those people are refferencing MAMP or XAMPP or sth. else. I'm however using Homestead
What could also be the problem?
Ok guys, I fixed the issue. I'm an idiot and should be ashamed. The reason it didn't work, was because I wasn't in my vagrant machine.
After doing vagrant ssh navigating to my project cd work/OpenLetter and doing php artisan migrate it worked of course.

Database SQL Dreamweaver connecting

When i connected mySQL databases to dreamweaver I only saw the default databases, none of the ones I created in myPHPadmin, I am running MAMP 2.2 on Mac OS X 10.7.5 Dreamweaver CS6, I am going to the databases icon on the right side of the screen in "App Developer Plus" viewing mode. I am trying to add a database with mySQL connection:
Connection Name: registration, mySQL server: localhost, Username: root, Password: my set password, Database <--- here is the error when I click select; it does not show the databaes I made in myPHP admin. called Registration and Dbank; I'm expecting to see these databases as I can see them in myPHPadmin. but in Dreamweaver after connecting to mySQL i only see: information_schema. mysql, performance_schema, and test.
Nothing seemed to work.. so I thought it could be an error created when i had installed mysql before installing MAMP, So i removed mysql standalone, and when I removed mysql, the databases no longer connected at all in dreamweaver. I got an error:
MySQL Error #2002
No such file or directory so THEN I have tried
Formating my computer and reinstalling all Dreamwweaver, MAMP, and re-enabling everything --> SAME ERROR :(
Setting the path in terminal to include /Applications/MAMP/Library/bin/mysql in .bash_profile --> SAME ERROR :(
In Terminal doing:
cd /var/
sudo mkdir mysql
cd (to get back to root)
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
--> SAME ERROR :(
Why can't Dreamweaver just connect to the databases.? PLEASE HELP!

Categories