Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm - How to setup a mysql database connection

Tags:

pycharm

I've just started programming Django in the PyCharm editor. I would like to setup a connection to a mysql-server on the Internet. So I clicked on Data Sources > DB Data Source.

Here's where the horror starts. I've to pick a JDBC Driver File, I don't know which one I need to choose, I suppose MySQL Connector. After that I need to pick a JDBC Driver Class, just guessing but I would take the com.mysql.jdbc.Driver. In addition I've to specify a Database URL beginning with jdbc://. I've never heard of JDBC and all that stuff.

Would be great if you could help me out here!

like image 527
Sean M. Avatar asked Sep 02 '12 23:09

Sean M.


1 Answers

Go to Data Sources and Drivers and press + button.

From Drivers list select MySQL.

If you are doing this for the first time a 'Download missing drivers files' will appear at the bottom of the window. If you click it, it will download the latest driver for this connection.
You can also click on the Driver: MySQL link > Go to Driver and go to drivers config page. JDBC Driver Class should be set to com.mysql.cj.jdbc.Driver by default. You can install older versions of drivers by clicking + button.

On Project Data Sources page fill in Host (IP or hostname), port (3306 by default), User and Password. Filling Databese is optional.

URL for connection should be jdbc:mysql://localhost:3306 or jdbc:mysql://localhost:3306/dbname if you specified database name.

Documentation: https://www.jetbrains.com/help/pycharm/data-sources-and-drivers-dialog.html

Here is Data Sources and Drivers window from PyCharm 2019.2.

Data Sources and Drivers

like image 120
mx0 Avatar answered Dec 11 '22 12:12

mx0