How to work in the same database by Workbench and terminal?

Asked

Viewed 143 times

-2

I created a database by Workbench

print do BD do Workbench

But I can’t find it through the Mac terminal. How to work in the same database? How to locate the database created by Workbench? And vice versa...

I’m connecting by command mysql -h localhost -u root -p through the terminal.

print tela terminal

  • 1

    Post as you are trying to connect, and the error displayed.

  • For starters, I’m a beginner and I’m taking a comic book course. I built a server on my machine through MAMP and then created the database through Workbench. Now I’m trying to work through the terminal. I installed Mysql but I can’t work in the same BD created by Workbench.

  • Tranquil Julio ! I think I know what it is, so I’ll post the answer to go with.

1 answer

1

What must be happening, is that you must be trying to connect in the following way:

mysql -u usuario -p senha -h localhost database_name

The right thing would be:


/Applications/MAMP/Library/bin/mysql --host=localhost -u usuario -p senha

So you pull the MAMP instance and not the local one (probably you have installed mysql locally)

Or it may be the other way around, you are connecting in the instance with the Workbench, and by the terminal in MAMP.

More alternatives:

Swap Mysql port on MAMP, and connect as follows:

mysql --host=localhost --port=9999 mysql -u root -p

Check the port of your instance and see if it is the one of MAMP:

mysql> SHOW GLOBAL VARIABLES LIKE 'PORT';
  • Thanks friend. It worked! I used the command of the second suggestion and it worked. Now I need to learn more about the concept of "instances" of a database.

  • Opa ! Jóia @Juliobarreto ! Don’t forget to mark as solved ! :]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.