0

I've just started to study Laravel using this course and I'm really sorry for the stupid question, but I don't understand some things. I use MySQL, so the database part of my .env file looks like this:

DB_HOST=127.0.0.1
DB_DATABASE=mysql
DB_USERNAME=root
DB_PASSWORD=root

Then I did migration:

E:\Laravel\Project\learning-laravel-5>php artisan migrate

And it worked just fine.

Migration table created successfully.
Migrated: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_100000_create_password_resets_table

But I really don't undertand how can I see these tables and where they are. Should I install phpMyAdmin or what?

2
  • The table is in MySQL database called mysql - that's one of the core databases and the MySQL daemon uses it for statistics and configuration. You shouldn't create tables in that database. You can use a tool like phpmyadmin, although it's a total and utter crap (it's fine for learning purposes, and it's also fine for malicious people to hack you at some point, use at your own risk). There are alternatives, proper GUI programs that don't depend on a web server - such as SQLYog and MySQL Workbench. Commented Dec 31, 2015 at 13:54
  • SQLYog is what I use for my day job and I really like it. They have a free community edition as well code.google.com/p/sqlyog/wiki/Downloads Commented Dec 31, 2015 at 13:58

3 Answers 3

1

They are stored in your local MySQL server. You can access them by using your MySQL client.

On linux:

mysql -u root -p

Then enter your password and from now on you're inside your MySQL client and can browse your database and tables.

Or you can install some GUI tool like phpMyAdmin.

Sign up to request clarification or add additional context in comments.

Comments

1

Yes, you can see the database and tables, once you install phpMyAdmin. These are the steps you can follow:

  1. Download phpMyAdmin from https://www.phpmyadmin.net/
  2. Add these lines to the file homestead.yaml

    folders:

    • map: /Users/{yourName}/Code/phpMyAdmin

      to: /home/vagrant/Code/phpMyAdmin

    sites:

    • map: phpmyadmin.app

      to: /home/vagrant/Code/phpMyAdmin

  3. Open your hosts file and add this line:

    127.0.0.1 phpmyadmin.app

And you are all set. Now open http://phpmyadmin.app:8000.

Refer for details at http://lab.dejaworks.com/phpmyadmin-installation-on-laravel-homestead-vagrant/.

Comments

1

Config

Here's a more extended example of what you can do in your environment in order to say to use mysql but then connect to a specific database created within MySQL:

DB_DEFAULT=mysql
DB_DATABASE=some_database_name
DB_USERNAME=root
DB_PASSWORD=secret

The DB_DEFAULT variable is saying to use the mysql connection type. The DB_DATABASE variable says to connect to a database within MySQL named "some_database_name".

Migration

To make matters a tad more confusing within mysql, there is a database named "mysql". With your setup, your migration has accidentally added new tables (users, password_reset) to the mysql database that's within you mysql server.

This database normally has meta data such as users and access, so mixing in application-related data there is not recommended.

Instead, we usually create a new database per application within MySQL. This can be done with this one liner (which will ask you for your password)

mysql -u root -p -e "create database some_database_name;"

Viewing MySQL Data

phpmyadmin is definitely one option to see the data in your database, but you'll need to install it, confgure it, etc. If you're using the command line, you can also check out the database manually there.

Here are some commands you can try:

mysql -u root -p
> # type in your password here, looks like it's "root"
# Now you get a mysql prompt

Then you can type some mysql commands/query:

show databases;
use mysql;
show tables;
select * from users; # assuming your table is still there

create database some_database_name; -- creates a new database table

If you're using Homestead or a virtual machine, you should be able to use something like SequelPro to view the database as well. How you connect a desktop client application to your mysql database depends on where the database is and how you current log into it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.