I am using Sequel Pro on Mac and trying to see my database schemas that Laravel created. In the migrations folder I see a users and password reset tables. I am trying to see them in sequel pro which I do not.
I used homestead and the vagrant box is up. The homestead.yaml is set to defaults to:
IP: 192.168.10.10
MySQL db: homestead
In the .env file I see the defaults too:
IP: 127.0.0.1
MySQL: homestead
User: homestead
Password: secret
I try to use both IP's but can't seem to connect and if I do connect with 192.168.10.10 I see 0 tables. What am I missing? New to Vagrant and Laravel too.
You should try to declare the DB connection to
config/databases.php
note that you can declare multiple DB connections here if you don't use .env for course.
then try php artisan cache:clear
Related
I've attempted to access my PostgreSQL database from both a Laravel project, DBeaver and Artisan. Accessing it from Laravel project or Artisan ($ php artisan migrate) always results in:
Illuminate\Database\QueryException
SQLSTATE[08006] [7] could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 5432?
Because I'm not relying in my Laradock settings and I'm not familiar with Laravel in general, I did re-download Laradock with default settings, but situation continues same.
Partial laravelProject/.env:
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=default
DB_USERNAME=default
DB_PASSWORD=secret
Partial laradock/.env:
POSTGRES_VERSION=alpine
POSTGRES_DB=default
POSTGRES_USER=default
POSTGRES_PASSWORD=secret
POSTGRES_PORT=5432
Environment used to run Artisan:
$ docker-compose exec --user=laradock workspace bash
I installed Laravel in this environment using composer global require laravel/installer.
DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=yourprojectdatabase
DB_USERNAME=default
DB_PASSWORD=secret
To connect using DBeaver:
Host: localhost
Port: 5432
Database: you can leave it empty
Username: default
Password: secret
Click on the PostgreSQL tab right there in Connection.
Make sure "Show all databases" is checked.
I can do migration to my homestead.
this is my .env
DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=54320
DB_DATABASE=intern
DB_USERNAME=homestead
DB_PASSWORD=secret
And I make a new server in my postgreSQL with
server name = Homestead,
username = homestead,
password = secret.
then, I did migration and all the table created into my database(server=homestead)
The problem is, when I want to do login in my site. It occurs an error:
SQLSTATE[08006] [7] could not connect to server: Connection refused↵
Is the server running on host "localhost" (::1) and accepting↵
TCP/IP connections on port 54320?↵could not connect to server: Connection refused↵
Is the server running on host "localhost" (127.0.0.1) and accepting↵
TCP/IP connections on port 54320? (SQL: select * from "users" where "email" = user#gmail.com limit
You have an extra 0 at the end of your port. Change DB_PORT=54320 to DB_PORT=5432
try to access your homestead with ssh.
i think u already change the password from the inside
from laravel documentation i think that config should work
or try this command after u change the config
php artisan config:cache and php artisan cache:clear
https://laravel.com/docs/5.6/homestead#connecting-to-databases
I am using phinx for migrations in my web app.
my phinx.yml:
paths:
migrations: %%PHINX_CONFIG_DIR%%/migrations
environments:
default_migration_table: app_migrations
default_database: app_database
development:
adapter: mysql
host: localhost:8888
name: app_database
user: ''
pass: ''
port:8889
I have mamp with ports apache:8888 and mysql:8889 running.
The database app_database does exist.
The table app_migrations does not exist(it will be created while migrating right?)
I already created some migrations and now i try to run them:
php vendor/bin/phinx migrate -e development
output in console:
Phinx by Rob Morgan - https://phinx.org. version 0.5.1
using config file ./phinx.yml
using config parser yaml
using migration path /path/to/directory/migrations
using environment development
using adapter mysql
using database app_database
Then it stops and nothing happens...
Anybody could help me with this issue?
Thanskj and Greetings!
Maybe there is some config-hickup. I know this phenomenon from conneting to a mysql-database that is not reachable via a specific host / port. This always leads to timeouts but only after eg. 60 seconds.
You wrote this in your config:
host: localhost:8888
[...]
port: 8889
First remove the port from the hostname:
host: localhost
port: 8889
and as second verify the mysql-server is really listening on localhost / port 8889.
You'll find more on in the "Configuration"-chapter of phinx-documentation: http://docs.phinx.org/en/latest/configuration.html
Regards
If you're using the default settings for MAMP, the username for the database would be root. Try changing the value of user in phinx.yml to root.
Ever since upgrading to the newest version of Laravel Homestead (v0.4.0), I'm having a weird issue where when I try to log in to Sequel Pro, it disconnects my Homestead SSH and does not let me back in unless I do vagrant suspend followed by vagrant up.
The error message it gives me is:
vagrant#homestead:~$ Connection to 127.0.0.1 closed by remote host.
Connection to 127.0.0.1 closed.
And when I then try and login via Sequel Pro I get the following error message:
Connection Failed!
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).
MySQL said: Can't connect to MySQL server on '127.0.0.1' (61)
My Sequel Pro settings are:
Name: Homestead
Host: 127.0.0.1
Username: homestead
Password: secret
Port: 33060
Worth referencing I have setup Sequel Pro as per this post here: http://www.tannerhearne.com/using-sequel-pro-laravel-homestead/
I actually solved this by using the following Sequel Pro settings:
Host: 192.168.10.10
Username: Homestead
Password: secret
Port: 3306
where 192.168.10.10 is the IP address of my vagrant box.
It seems the new Homestead update (v0.4.0) rendered my previous settings, useless.
I'm learning to use Homestead 2.0. I have a existing MySQL database on my local machine. If I create a new laravel 5.0 project on homestead virtual machine, what should I do to connect to existing database?
If I need to migrate database on Homestead, how should it be done?
If I can connect to my database from Homestead, how shall I configure it on Homestead?
Thanks.
I had the same problem; this is how i resolve it
I was developing a laravel 4.2 project with WampServer as development environment, later I decided to change to laravel homestead as development environment
Steps:
Save your database as .sql file (my case: exported from phpMyAdmin and saved as db.sql)
Put the .sql file in the root of your project
Navigate to your homestead directory
C:\Users\chebaby\Homestead (master)
Get into the vagrant box
vagrant ssh
Navigate to your project root within the box (where you saved early the darabase .sql file in my case: db.sql)
vagrant#homestead:~$ cd Code/project-folder/
Login to mysql
vagrant#homestead:~/Code/project-folder$ mysql --user=homestead --password=secret
to check if your database already exist run
mysql> show databases;
Else create your database by running this command
mysql> create database yourdatabasename;
Now that you are sure your database is created, exit mysql back to the vagrant prompt
mysql> exit;
Imports the database file by running this
vagrant#homestead:~/Code/project-folder$ mysql --user=homestead --password=secret yourdatabasename < db.sql
All you have to do is to check if your existing database is succesfuly imported
Login to mysql
vagrant#homestead:~/Code/project-folder$ mysql --user=homestead --password=secret
then run
mysql> use yourdatabasename
To show the tables run
mysql> show tables;
hopefully this answers your question
Additional Resources
Laravel Homestead- MySQL default credentials and database
How to import an SQL file using the command line in MySQL?
Treat your Homestead Installation as if it's a remote host operating on a completely different machine. Homestead doesn't know anything about your localhost, and therefore cannot connect directly to your locally hosted MySQL databases.
Your Homestead installation operates on its own IP address. Whatever IP that is (likely 192.168.10.10), you can connect to it using MySQL Workbench or SequelPro using the following credentials:
Host: Your Homestead IP
Port: 3306
Username: homestead
Password: secret
You can find your IP by opening the following file:
~/.homestead/Homestead.yaml
If you're on Windows, then it would likely be:
C:\Users\your-username\.homestead\Homestead.yaml
In order to interact with your database, make sure Homestead is running first by running vagrant up in your Homestead directory, otherwise it will error out.
After that, you can export your local database and import it back into one of your Homestead databases using the credentials described above.
Note that Homestead is a separate environment and cannot access the DB on your host machine. Laravel Homestead comes with a mysql database installed. You should use this mysql for the code running in the Homestead. One easy way to solve your problem is to install phpMyAdmin on Homestead box and and then import the DB to mysql in Homestead.
Steps to install phpMyAdmin:
Got the below answer from here and added my notes
Download latest version of phpMyAdmin from https://www.phpmyadmin.net and extract it into a directory in your host machine.
Note: I extracted to /var/www/phpmyadmin/public. Here public directory is important otherwise you will receive No input file specified. error when you access phpmyadmin.
Configure homestead.yaml file to add a site where you can access phpmyadmin
folders:
- map: /var/www/phpmyadmin
to: /home/vagrant/code/phpmyadmin
sites:
- map: phpmyadmin.app
to: /home/vagrant/code/phpmyadmin/public
Add this line to your \etc\hosts file:
192.168.10.10 phpmyadmin.app
Note: 192.168.10.10 is the ip in my homestead.yaml configuration file.
Now start the vagrant by running vagrant up and you should be able to access the mysql of homestead by going to the url phpmyadmin.app. Now that phpmyadmin is installed you can import your DB easily.