I’m working mostly Back-end with many different technologies, like docker, GraphQL, TypeScript, MySQL and Some other technologies. I’m also learning a lot of important things that make me a better developer, like Unit Testing, working with Microservices Based Infrastructure. DBeaver Universal Database Tool Free multi-platform database tool for developers, database administrators, analysts and all people who need to work with databases. Supports all popular databases: MySQL, PostgreSQL, SQLite, Oracle, DB2, SQL Server, Sybase, MS Access, Teradata, Firebird, Apache Hive, Phoenix, Presto, etc. The docker image will execute files with extensions.sh,.sql and.sql.gz that are found in /docker-entrypoint-initdb.d in alphabetical order. In a lot of docker image, the sql scripts found in the /docker-entrypoint-initdb.d/ folder. You can populate mysql services by mounting a SQL dump into that directory. IPGRAY: DBeaver - how to export mysql table data using DBeaver client.
DBeaver is an awesome SQL client and database management tool.
It comes with drivers for the most popular databases, including MySQL, PostgreSQL, SQLite and many others, meaning you can learn one tool and use it across projects built on different technology stacks. How awesome is that?
Bellow are the steps you can use to connect your DBeaver client to a remote database server via SSH.
Note that you only need to do these steps once. The connection configurations will be saved and you can re-use them by right-click + connect.
This guide is created using DBeaver version 6.3.
Method 1: DBeaver via SSH with plain password
1. Create a new connection
Create a new connection by right clicking in your Database Navigator area.
2. Fill SSH details
Fill details under the SSH tab, and click Test tunnel configuration.
You should see a success message if the details were correct.
3. Fill database’s details
Now that DBeaver can connect via SSH, let’s go back to the General tab and fill in the database credentials:
Clicking Test Connection, you should see a success message. Click Finish.
Method 2: DBeaver with encrypted openssh private key file
If your server requires an openssh private key to login, follow the bellow steps:
1. Add SSHJ to DBeaver
You can do it by opening Help/Install New Software… and typing the following link: https://dbeaver.io/update/sshj/latest/
2. Connect
Use the same steps as Method 1, but adjust as follows:
- On the SSH details menu (step 2), provide the password for your encrypted private key file.
Select SSHJ, under Implementation.
- Change Authentication Method to Public Key.
Select your Private Key
- Click Test tunnel configuration and Finish.
Resources
If you need additional help, this link may be very useful.
What are we trying to do ?
- Run MySQL as a docker container in Local
- Connecting to it from command line.
- Connecting to it from DBeaver.
What should we have already ?
- DBeaver (Or any other Application that you use to connect to MySQL)
How can I start ?
RUNNING MYSQL IMAGE IN LOCAL
Run the following command (only after reading the explanation below and substituting it with your own values)
Lets breakdown this command into parts
- docker :- The command to invoke docker
- run :- To create a docker container uses the mysql at the end to determine which docker image it should run. if mysql image is not available in local the latest will be downloaded from docker hub.
- -p :- Tells to map the port 3306 of localhost to 3306 port of the container
- –name :- Sets the name of the container
- -e :- Sets the environment variable. In this case sets the MYSQL_ROOT_PASSWORD
- -d :- Tells to run docker as detcached (not attached to the current terminal but in background)
CHECK IF IT IS RUNNING IN LOCAL
You can see a list of running containers using the following command
CONNECT TO MYSQL IN CONTAINER VIA COMMAND LINE
1. Open the command line inside the container using the following command.
docker exec -it <containername> /bin/sh
2. Type the following commands to login to the instance
3. Enter the password to login
4. If every thing went well we will see that the cursor is mysql>
5. Type some commands to test it.
CONNECT TO MYSQL IN CONTAINER WITH DBEAVER
1. Open Dbeaver
2. Add a new Connection
3. Select MySQL from the list
4. Click Next and fill in the password, you can test if everything works fine using the Test Connection option.
5. If everything went well the test connection will succeed and you can click finish. On doing that you will be able to see the connection in the Database Navigator pane.
6. Sometimes you get an error public key retrieval is not allowed, in this case go Driver properties tab and in that tab you will be able to see a allowPublicKeyRetrieval property, set that to true. ( Note that AllowPublicKeyRetrieval=True
could allow a malicious proxy to perform a MITM attack to get the plaintext password, so it is False by default and must be explicitly enabled.)
START, RESTART, STOP CONTAINERS
Start a docker container using docker start <containername>
Stop a docker container using docker stop <containername>
Restart a docker container using docker restart <containername>
Dbeaver Mysql Dockery
Remove a stopped docker container using docker container rm <containername>
Dbeaver Mysql Dockers
Feel free to write your thoughts as comments or email