local ・ Mac ・ MySQL Workbench ・ VagrantFile
Virtual environment ・ Vagrant ・ CentOS7 ・ MySQL
I wanted to operate MySQL installed on Vagrant locally with MySQL Worchbench. Try that connection. It is assumed that MySQL is already installed on Vagrant.
Set the IP address that can connect to the virtual environment from the host OS. If you uncomment it like this, it's OK.
# Create a private network, which allows host-only access to the machine # using a specific IP. config.vm.network "private_network", ip: "192.168.33.10"
Then reread the settings with vagrant up or vagrant reload.
After doing vagrant ssh, connect to MySQL in the virtual environment.
mysql -u root -p
If you have set a password in advance, enter that password (omitted) and go to the point where you can operate mysql.
Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.7.29 MySQL Community Server (GPL) Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
Even if you describe the correct connection destination in Workbench, it will be played like the following, so please grant the authority of external connection. I was a little addicted here because I couldn't connect even though I was pinging ...
192.168.33.1' is not allowed to connect to this MySQL server
↑ When establishing a connection with Workbench. Type a command to grant permissions in MySQL.
mysql> GRANT ALL PRIVILEGES ON *.* TO [email protected]'192.168.%' IDENTIFIED BY 'root password' WITH GRANT OPTION;
Now, if you can execute Query OK, 0 rows affected, 1 warning (0.00 sec), you are ready for external connection.
Finally, let's check if we can connect with Workbench. If you can confirm the connection with a test connection and confirm that you can execute the query appropriately, you are done. Thank you for your hard work.