How to install Oracle Database on Mac OS (Any Version)

25 Apr 2014 Update: This guide has been originally written 2 years ago describing Oracle 11gR2 DB installation. Now it has been revised for the latest Oracle 12cR1 DB.

Introduction

Installing Oracle DB on any Mac OS version is not an easy task. Official support was dropped from 10g onwards around the early days of Mac OS X and since then there has been endless questions online of how to go about later versions like Leopard (10.5), Snow Leopard (10.6), Lion (10.7), Mountain Lion (10.8) or Mavericks (10.9).

I have yet to find a consistent resource online of how to natively install the database and I have also tried my hands on binaries compilation and package transfers along all the previous versions with various, inconsistent results. I have to admit that this long-winded process gets too complicated for my taste and patience.

The people at Oracle have acknowledged this problem and have provided a neat solution abstracting all the complicated noise, packing up all the required tools and needed configurations in a single image file readily to be hosted as a VM in VirtualBox.

This is old news and although VirtualBox is well documented I haven’t again found a single resource that is describing the process from top to bottom for my setup which is a Macbook Pro using WiFi therefore this detailed tutorial.

*General Note: As the creators suggest Oracle XE should be used for testing purposes only. Also the majority of passwords on the VM have been setup by default to oracle and should be changed for obvious security reasons.

Step 1: Getting VirtualBox

This is as simple as any other installation on a Mac. All we have to do is grab our x86 version (assuming an Intel CPU) for Mac from the official download page.

25 Apr 2014 Update: Currently VirtualBox is @ version 4.3.10 and doesn’t seem any different.

Step 2: Getting the VM file

This is the download page and the download instructions are clear. The ova VM file is big ~4G so better start the download process on a browser that has an integrated download manager like Firefox if you have a slow connection or are frequently experiencing dropped connections.

Apparently this VM has been initially created for a developer’s workshop but gets frequently updated with the latest and greatest of Oracle Client, Oracle SQL Developer and other tools. Various walkthroughs and other interesting tutorials are loaded-up on the VM awaiting to be discovered but all we care about is the Oracle 11gR2 DB which will be by default up and running when the VM is loaded into memory.

25 Apr 2014 Update: This is still the go-to place to get the OVA file. The difference is that the size of the file now spans ~ 5.22GB and has been prefixed with “OTN_” in the name. And of course it sports the latest Oracle 12cR1 DB along with the latest SQL Developer 4.

Step 3: Installing the Guest VM

Our host OS is apparently Mac OS and the guest VM is Oracle Linux 5 which is a branch off Red Hat Linux.

From the VirtualBox Menu we select File > Import Appliance

Then we make it point to the VM file we’ve just downloaded:

Import Virtual Applicance-2

VirtualBox-1

25 Apr 2014 Update: In the picture above as mentioned in the previous section the name should be “OTN_Developer_Day_VM.ova” and the size ~ 5.22GB.

25Apr14-1-importOvaToVirtualBox

Click here for an older version of the picture above installing version 11gR2

 

After the import gets completed we are ready to start the VM:

25Apr14-2-importedIntoVirtualBox

Click here for an older version of the picture above installing version 11gR2

 

Step 4: Starting the VM

Starting up the VM is as easy as inserting oracle/oracle when we are prompted for username/password:

25Apr14-3-loginScreen

Click here for an older version of the picture above installing version 11gR2

When the OS boots up we are ready to go:

25Apr14-4-loggedIn

Click here for an older version of the picture above installing version 11gR2

Step 5a: Making Oracle DB visible  – Internet Connectivity

On the top right of the VM there should be an icon denoting Internet connectivity on the VM. If by default it is disabled it might need a kick to connect and as long as your Host OS has Internet connectivity it will connect without issues:

25Apr14-5-disconnectedByDefault                     25Apr14-6-connected

Step 5b: Making Oracle DB visible – Firewall

This is a tricky step that we didn’t need to perform 2 years ago on that flavour of OracleOS that was hosting 11gR2.

Basically the OracleOS Firewall is activated by default. So we have two solutions:

Solution 1 – Switch-off the OracleOS Firewall altogether

The Firewall is accessible via System(top left)>Administration>Firewall

25Apr14-7-accessFirewall

 

On the Firewall Configuration panel click on the Disable button and then the Firewall disabled should look like this:

25Apr14-8-FirewallDisabled

Solution 2 – Allow port 1521 in Firewall to be accessible remotely

25Apr14-9-FirewallPort1521Trusted

Step 5c: Making Oracle DB visible – VirtualBox PortForwarding

By default VirtualBox > Devices > Network Adapters is attached to an internal NAT that should hopefully give you access to Internet.

Oracle Developer Days - Network

My setup is a MacBook Pro that is getting Internet via WiFi therefore I’ve tried to get the Bridged Adapter via WiFi to work that is initiating a more direct connection between the Host and Guest VM but to no avail. I’ve tried several things suggested out there such as reducting the MTU to 1496 or downgrading to IPv4 but without luck.

The solution lies in the Port Forwarding option under the Network Adapters picture above:

VirtualBox VM

Here we define external requests coming from localhost (127.0.0.1) to the standard Oracle communication default 1521 TCP port to be forwarded to our Oracle VM with IP address 10.0.2.15 on the same port. The IP of the Oracle VM can be found by issuing ipconfig command on the terminal (3rd line, inet addr):

25Apr14-13-findTheIPAddr

Click here for an older version of the picture above installing version 11gR2

Step 6a: Testing external connectivity – via Telnet

From the Host OS (Mac OS X Mavericks) we can test that we can connect to localhost at port 1521:

25Apr14-15-telnet

 

Step 6b: Testing external connectivity – via IDE

Also by using IntelliJ (13.1 in this example) datasource capabilities we can successfully connect to the Oracle’s Sample HR database (username: hr, password: oracle):

25Apr14-11-HRDBFromIntelliJ

Click here for an older version of the picture above installing version 11gR2

25 Apr 2014 Update: Note the correct connection jdbc url:

jdbc:oracle:thin:@//127.0.0.1:1521/PDB1

In prior version 11gR2 it used to be (but this does not work anymore):

jdbc:oracle:thin:@//127.0.0.1:1521:orcl

Step 6c: Testing external connectivity – via SQL Developer

SQL Developer 4 @ Mac OS X Mavericks:

25Apr14-12-HRDBFromSQLDeveloperIMac

Click here for an older version of the picture above installing version 11gR2 sporting SQL Developer 3 at the time

Conclusion

That’s a quick, clean and bulletproof way of having the most recent Oracle DB running on a Guest VM not only on Mac OS but on any OS.

PS. If you have a Synology NAS like I do, you might want to check out my detailed tutorial on how to host the VirtualBox VMs on the NAS and connect to it via the supported iSCSI protocol by VirtualBox clients installed on any home/work computer.

Advertisements

65 comments on “How to install Oracle Database on Mac OS (Any Version)

  1. hi i have aan airbook with mountain Lion OS. will i be able to install oracle db if i follow the above steps… many thanks

  2. fantastic tutorial. I got this up and running in less than 30 minutes, not including download time. I have one question. Now i have this installed how do i use the mac environment to code in. Here i have to remain in the Linux virtual environment, and its not that enticing. Thanks.

    • As long as you have setup the correct port to listen to then you can do development in Mac OS and treat the DB directly visible, as if it was natively installed. You don’t have to use the Linux Oracle OS for any other purposes. Just to host the Oracle DB and then make it visible/accessible from outside.

  3. Hey thanks a lot for this. I am new to IntelliJ IDE…could you please tell me where I can make the datasource connection to the database? I would really appreciate that.

    • Hi Rommel, all you have to do is go to View > Tool Windows > Data Sources > click on the + sign > Add Data Source > New Data Source and fill in the details of the driver/url/username/pass. In some cases it even points you to the needed driver or provides an option to auto-download.

  4. Hi Dimitrisli….thanks once again! 🙂 It works like a charm now…a little sluggish in the beginning while it loads the schema but right after it handles smooth. I personally was looking for something like this. Personally I dont like to install a local instance of Oracle on my MAC…or any computer that I own in that matter…this works well. Let me ask, have you have any experience in creating new schemas in this way? I am asking because I am getting ready to deploy a third party application using Tomcat to instantiate a call to the DB on the VM for its schema…of course I would like to know if you had any troubles in creating a new schema directly?

    • Hi Rommel, of course you can run DDL/DML scripts like you are used to in any other Oracle instance. I have yet to experienced any problems myself. The VM Oracle instance works perfectly fine.

  5. Hi Dimitrisli – excellent. I am working on installing Informatica and Business Objects. Can you pls let me know how i can install such softwares ? Thanks

    • Hi Yuga, I don’t have experience with Informatica myself but if you can do so in a natively installed Oracle instance I cannot see why it wouldn’t work equally well on a VM instance.

  6. Hi Dimitrisli
    It is really helpful topic for someone who’s new to these kind of things.
    Could I ask you how to connect SQLDeveloper with linux created in VM? What kind of details should I use when I set up connection taking example above under consideration?
    Much appreciated!

  7. Hi Dimitrisli, quick response, much appreciated.
    I should be more specific, apologies for this.
    What I want to achieve is to have SQLDeveloper on MAC and DB in linux installed on VM therefore I am guessing (like I said, I am new to this) I should somehow root DB on linux to SQLDeveloper on MAC? Is this even possible? Thank You

  8. Your article is a revelation.

    Everything worked as promised, except I can’t make the connection!

    SQLDeveloper reports: “… IO Error: The Network Adapter could not establish the connection”

    The attempt in Terminal looked like this:

    [Herberts-MacBook-Pro:~] herbharrell% telnet 127.0.0.1 1521
    Trying 127.0.0.1…
    telnet: connect to address 127.0.0.1: Connection refused
    telnet: Unable to connect to remote host

    I have carefully gone over the settings, esp. for port forwarding, and have no clue what is wrong.
    Where would you look?
    Thanks,
    Herb Harrell

    • Hi Herb,

      thanks for your kind words. Sorry for coming back late on this. Take a look at my updated article that is addressing a few extra points in Oracle 12cR1 that weren’t there in Oracle 11gR2 (all inside the OracleOS VM) and let me know if you still have problem.

  9. Thanks, but it does not works for me.
    Telnet is ok.
    IDEA is failed.
    Connection to oracle failed
    java.sql.SQLException: Задан неверный URL Oracle
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:448)
    in RemoteDriverImpl.connect(RemoteDriverImpl.java:27)
    at com.sun.proxy.$Proxy103.connect(Unknown Source)
    in LocalDataSource.getConnection(LocalDataSource.java:158)

    • Sorry for coming back late on this. Take a look at my updated article that is addressing a few extra points in Oracle 12cR1 that weren’t there in Oracle 11gR2 (all inside the OracleOS VM) and let me know if you still have problem.

  10. The problem is column symbol after thin

    Wrong
    jdbc:oracle:thin@127.0.0.1:1521:orcl

    Right
    jdbc:oracle:thin:@127.0.0.1:1521:orcl

    • I don’t believe I had it as a typo or wrong in the images but indeed there is a difference in the jdbc url string between 11gR2 and 12cR1 which I explicitly denote in the updated version of my tutorial.

  11. This tutorial is awesome, so many thanks to you for your contribution to the ones who have self study on oracle certifications. Best regards from Turkey

  12. I followed all the steps as mentioned but getting error like below “got minus one from a read call oracle sql developer”

    I have installed latest VM image which has Oracle12c but when trying to connect from sql developer giving above error.
    Chacked all relevant settings and files like tnsname,listener,sqlnet
    Tried with different adapters but in vain.
    Any more suggestions

  13. Thank you so much for the awesome tutorial. I am preparing for my job interview and this saved me TONS of time.

  14. I routinely connect to a remote Oracle DB via sqlplus from my MacBook Pro’s Terminal app, and freely use sqlplus to manage the DB.

    Is it similarly possible to connect via sqlplus from Mac’s Terminal app to the Oracle DB running locally in VirtualBox?

    This would be a (very useful) FOURTH case of external connectivity, standing beside the cases 6a, b, and c described in the tutorial.

    Can anyone supply missing section 6d?

  15. I’m so happy I found your blog. Thx for providing detail and updates….I will be sharing your blog with other classmates.

  16. Great update Dimitri! After spending a day and a half trying to fix a Win7+Oracle VmWare image while getting ready for a class (something broke all oracle db connectivity inside of the image)… stumbled across this, and was back up and working natively in OS in a half hour.

  17. Wow! This explanation is the better I’ve found on the Internet. It was a breeze setting it up since I had already VB running on my Mac. Thanks a lot mate.

  18. Great tutorial, thanks a lot for taking time in explaining this 🙂

    There’s a typo there when you say that the IP of the virtual machine can be found using the command “ipconfig” instead of “ifconfig”.

  19. HI Dimitris and thank you for the very nice help! Finally i made it and connection alredy exist in SQL developer! finally i can work in my MacBookPro with Batabases!

  20. Excellent article. I was of the thought to forget Oracle installation on my mac. Now I have installed it successfully. Thank you.

  21. Very nice tutorial 🙂 Did help a lot. Just some notes, with the latest download you do not have to change the firewall settings nor the port forwarding… looks like some oracle guy read your tutorial as well and they put it in the latest VM-Image :D.
    Unfortunately the url to connect to the db changed as well, it is now
    jdbc:oracle:thin:@//127.0.0.1:1521/orcl
    you can connect with
    user: system
    pass: oracle

    Thank you for this article!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s