permaculture playing cards
The moose likes JDBC and Relational Databases and the fly likes mySQL connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "mySQL connections" Watch "mySQL connections" New topic

mySQL connections

tom davies
Ranch Hand

Joined: Apr 27, 2012
Posts: 168
I wasn't really sure where to put this, but i will stick with here for now.
I have installed mySQL onto my mac and i want to create some java programs which will connect to it, i have yet to create the database so when i try and connect i get an error message saying Unknown database 'databaseName'.
Could anyone tell me how to access mySQL to create this new database via the terminal? I have searched and nothing so far seems very clear. Alternatively is there any programs that would help manage the databases? i have used phpMyAdmin online but not locally. I assume all i need to do for this small problem is access via terminal and create the database though?
Henry Wong

Joined: Sep 28, 2004
Posts: 20142

One option is to use the command line tool to connect to MySQL -- which for MySQL, I think it is simply "mysql". From there you can just do a "create database" command to create the database, followed by "create tables", unless of course, you want your application to do that.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Tony Docherty

Joined: Aug 07, 2007
Posts: 2737
Not sure about mac's but for windows MySql comes with a command line program called MySQL.exe which allows you to execute SQL statements.
If you want a GUI based tool try MySQL Workbench which I believe is available for the Mac.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 44472
You will find the JDBC tutorial here, and there are lots of SQL tutorials on the web. That will probably get you started off. There is also a MySQL handbook which you can download.

This thread would fit better in our databases fora, as somebody told me, so I shall move it.
tom davies
Ranch Hand

Joined: Apr 27, 2012
Posts: 168
Thanks guys, MySQL workbench was the program i was thinking of, i just couldn't remember the name after using it a while ago.
Connection is established and database is created.
I agree. Here's the link:
subject: mySQL connections
It's not a secret anymore!