How to install Oracle Database on Mac OS Sierra 10.12 or above

Image for post

If you want to create an application using oracle database in a Mac OS you might stumble in the issue of how to install the database and which tools to use.

The first response you get is via VirtualBox. It?s one way to do it but it?s a very heavy solution. You will have to install the software, download Oracle Database Virtual Machine which is around 7 Go and finally configure ports. And don?t forget system requirements you have to fill to be able to execute the virtual machine. They can be found here https://www.oracle.com/technetwork/database/enterprise-edition/databaseappdev-vm-161299.html

Image for post

All this make the virtual machine a hard choice.

A very lighter way is to use Docker container to store the database and use SQL developer to connect to it.

I will describe steps to get Oracle running with Docker container.

Install Docker

First download Docker for Mac from the official website.

You will need to create an account to do so. It?s really fast and you need to only enter a Docker ID, a password and email. You will need it to install more tools from Docker and manage you container.

Once you download the Docker.dmg file, double click on it and you will just have to drag and drop the icon into the Application folder.

Image for post

Now go to the application folder and run docker.

You will see the docker icon on top right in your screen.

Image for post

You can check if it?s running by clicking on it.

Image for post

Or you can launch the command below in a terminal.

“`docker version

Image for post

The is several tasks you can do like run Kitematic which I will introduce later.

Store the Oracle Database Image in your Docker

Now you need a Database to store in your docker.

Several database images are available in docker. In this tutorial, I use truevoly/oracle-12c image. You can use it if it?s still available. Otherwise you can search for oracle-12-c images in docker website.

In a terminal run this command to store the database image in your docker.

docker pull truevoly/oracle-12c

The following message is printed once it?s done :

Status: Downloaded newer for truevoly/oracle-12c:latest

Create the container

The container will allow you to store the database locally.

The first step is to create a folder for the image.

mkdir ~/oracle_data

Now we create a container and mount it in the latest folder using the oracle-12c image. The command will also run the instance.

docker run -d -p 8080:8080 -p 1521:1521 -v ~/oracle_data/:/u01/app/oracle truevoly/oracle-12c

A hash will be generated at the end of the execution.

You can check if the container is running with this command :

docker psImage for post

Use Kitematic to manage the container

Kitematic is a legacy desktop solution that helps you manage docker containers with a user interface.

You can download it here https://kitematic.com/docs/.

Once it?s installed open it and you will see the running container inside.

Image for post

Create databases in command line

You can use the terminal to connect to the database but it?s better use a client.

It?s easier to manage this way.

If you still want to use command lines, it?s accesible in kitematic.

If you click to EXEC button, a terminal will open.

You can connect to sqlplus with this command :

sqlplus system/oracle@//localhost:1521/xeImage for post

User and databases are the same in oracle-12c, so you can create them in this console.

Use SQL developer

You can download sql developer from here. Decompress the zip file and put it in Application folder.

Now open you SQL developer.

You can test the connection to your oracle database using the username system and password oracle. Choose any connection name. You can use the default hostname, port and SID.

Image for post

The connection is established.

For example, you can run this script in Sql developer to create a new database named TEST.

CREATE USER TEST IDENTIFIED BY passtest DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE temp QUOTA 250M on USERS;GRANT CONNECT, RESOURCE, DBA TO TEST; GRANT CREATE SESSION TO TEST; GRANT CREATE TABLE TO TEST; GRANT CREATE VIEW TO TEST; GRANT CREATE ANY TRIGGER TO TEST; GRANT CREATE ANY PROCEDURE TO TEST; GRANT CREATE SEQUENCE TO TEST; GRANT CREATE SYNONYM TO TEST;

Feel free to comment and clap if you find this article interesting.

Follow Mohamed Fofana to get notified of my next post.

No Responses

Write a response