Return to site

Simple Database For Mac Os X

broken image


Introduction

For Mac OS X, trash the program icon from the system's Applications folder. For Windows, select the Uninstall myBase Desktop 7 menu item from the Start menu, and press the 'Yes' button to proceed. Note that you may want first to create backups for your own.nyf database files before uninstalling the software. EagleData 0.64 EagleData is a simple but flexible database. It is useful to file your addresses, catalogue your cds, games, or video-collection, etc. Bento - Personal Database 4.1.2 for Mac is free to download from our application library. Our antivirus analysis shows that this Mac download is malware free. The software lies within Productivity Tools, more precisely Timekeeping. This Mac application is an intellectual property of MacMedia. This application works fine with Mac OS X 10.5 or later. JumpBox for the PostgreSQL Relational Database Management System for Mac Free JumpBox Mac OS X 10.4 Intel/Server, Mac OS X 10.5 Intel/Server/.6 Intel, Mac OS X 10.6/Intel Version 1.1.5 Full Specs. Knack is the best database software for Mac.

OrientDB is an open-source NoSQL multi-model database which helps organizations to unlock the power of graph databases without deploying multiple systems to handle other data types. This helps you to increase performance and security while supporting scalability. Platform: Linux, Mac OS X, Windows, Solaris, and HP-UX.

Postgres is a powerful and free object-relational database management system. It has gained a lot of momentum since its introduction in 1995 because of its robustness and powerful features it ships with out of the box. In this article, we'll walk through the process of installing a Postgres database on a Mac OS X machine and set it up for Ruby on Rails development.

Install Postgres Database with Homebrew

Homebrew is a popular package manager for OS X. To install Postgres with Homebrew, follow the steps below:

The first thing to do is install Homebrew if you haven't done so already. Homebrew site has a simple command that you have to paste in your terminal to do so. Make sure to accept the command line developer tools installation if prompted.

Next, run brew install postgres to install Postgres. It might take a little while to compile and install. After compilation is done, it'll give you some instructions to finish setting it up.

The database will be initialized during installation, so there isn't a need to run initdb to finish installation of Postgres via Homebrew. Near the end of the installation instructions you should see mention of the command brew services.

If you don't already have brew services installed. It may be installed withthis command:

And then you can run the following command to start Postgres as a background service:

Postgres will also restart automatically at login after you have run the command above.
Once Postgres has started, we can use brew services to stop it manually:

Or we can also use brew services to restart Postgres:

Now you should have PostgreSQL all set up.

Set Up Postgres to Work with a Rails App

First, install the pg gem:

Make sure you include the pg gem in your Gemfile, and run

Now, set up your config/database.yml file to point to your Posgres database.

Let's create the development and test databases:

Now you can run pending migrations, if there are any.

The rest of this chapter will walk through the installation of popular databases on the Mac OS X platform. Each database has pros and cons, and your decision to use a specific database will probably depend on its performance, functionality, and price. You should browse the O'Reilly library for more extensive coverage of these databases before making your final decision.

12.2.1 MySQL

MySQL is a popular, lightweight, open source relational database. Many developers support it, which makes it an ideal database on which to start the RDBMS learning process. Over the years, MySQL has evolved, adding an increasingly broad range of sophisticated features. Still, its most popular use is as a storage mechanism for dynamic web applications?specifically those built using open source languages such as Perl and PHP. It is also an extraordinarily solid database for small, JSP-based web applications.

12.2.1.1 Installation

Installing MySQL on Mac OS X is fairly straightforward. First download a distribution of MySQL. A prebuilt Mac OS X binary is available at http://www.mysql.com/downloads/.

Currently, an ideal download is MySQL 3.23, which is the one you'll use here. You can get it at http://www.mysql.com/downloads/mysql-3.23.html.

Scrolling through the list, you'll notice versions available for Windows, Solaris, FreeBSD, and Mac OS X. The availability of a Windows version sometimes makes MySQL a better choice than PostgreSQL (discussed later in this chapter).

The specific version used here is MySQL 3.23.55 for Mac OS X 10.2. You might notice that the last revision number for MySQL is updated frequently. Be sure to stay on top of the release notes to look for bug fixes for problems you may have.

When you click on the download link (I grabbed the 'Standard' version rather than the 'Max' version) and select a mirror site, you'll end up with a .tar.gz file. Double-click on it, and assuming your StuffIt Expander is installed, the file will be expanded into a new folder called mysql-3.23.55-apple-darwin6.1-powerpc. Move this folder into a location you can remember. For the rest of this discussion, assume that the files are installed in /Developer/mysql-3.23.

The folder/directory name is shortened to make it easier to type, but the version number remains to ensure that you can easily remember which version you are using. Later, you may wish to test or upgrade to another version, and you'll want this version information to keep things straight.

Next, go to the Apple menu, select 'System Preferences . . . ', and click on 'Users.' Add a new user, name the user mysql (for both the full name and the short name), and select an icon for that user.

Don't forget to assign a password to the mysql user (and remember the password). You can also use the NetInfo Manager to create new users that won't be visible in login screens, without a home directory, etc. For more information on NetInfo, consult Mac OS Xfor Unix Geeks by Brian Jepson and Ernest E. Rothman (O'Reilly).

Once you've installed MySQL, you'll need to perform some additional steps to get it running on your system. Open up the terminal, and navigate to the bin directory of the folder where you placed your MySQL installation.

Issue the commands as shown here to complete the software portion of the installation:

Now, set the permissions for the various directories:

This code assumes you created the mysql user, so be sure it is created before attempting these steps.

12.2.1.2 Starting MySQL

Now launch the server:

If you have already performed a sudo in the last five minutes or so, you'll be able to execute this command with the & to put it in the background. If a longer time period has elapsed since sudo-ing in, though, you may be prompted for an administrative password. If you're having trouble, open a new terminal and execute the command without the &, or execute a sudols to force a password check.

Next, set passwords for MySQL's default administrator account. Follow the steps shown here (replace the text 'groovy' with your choice of password, but retain the quotation marks):

Now test the connection to the database:

After being prompted for the administrator password, you should see a MySQL status message go by that displays the database connection ID and server version. At the mysql> prompt, enter the showdatabases; command:

You should see a formatted display listing the mysql and test databases. Type exit at the prompt, and you'll return to the command shell.

12.2.1.3 Stopping MySQL

Shut down the database by entering the following command:

As you can see, most of the work around MySQL involves the mysqladmin and mysql commands. You should play around and become familiar with them, as they will be your mainstay in database work.

12.2.1.4 Creating a database

Now that you've gotten a handle on the basics, restart the database and get back into the MySQL monitor shell by executing the commands shown here:

You'll be prompted again for a password. At the MySQL prompt, create a new database and user. Replace the text 'special' with your own password, retaining the quotation marks:

Simple
12.2.1.5 Working with a database

Before issuing SQL commands to work with a database, log back in to the database:

After entering your password again, you'll see the mysql> prompt. To start working with the macjava database, type the following command:

You're now all set to begin adding tables, columns, and data to the database. To test this code, enter some SQL as shown:

To learn how to create tables and add sample data, see the next chapter.

12.2.1.6 MySQL JDBC configuration

You can download the MySQL JDBC driver (now known as Connector/J) from http://www.mysql.com/downloads/api-jdbc-stable.html (follow the links to a local mirror). Make sure the resultant JAR file (mysql-connector-java-2.0.14-bin.jar in my case) is on your classpath.

Bing For Mac Os X

If using Version 2.0.14 or later, you'll use com.mysql.jdbc.Driver as your driver class (prior releases used org.gjt.mm.mysql.Driver). The JDBC connection URL is in the form jdbc:mysql://127.0.0.1/databasename. Replace 127.0.0.1 with the hostname of your MySQL server, and you know what to do with databasename.

12.2.2 PostgreSQL

PostgreSQL is another popular open source database. Like MySQL, PostgreSQL is free, easy to run, and great for development work. While it doesn't offer a native installation for the Windows platforms, it is a little heavier-duty than MySQL, so it often finds a place in open source production environments.

12.2.2.1 Installation

The easiest way to install PostgreSQL is to download a prebuilt package from http://www.osxgnu.org/software/Database/postgresql/. PostgreSQL prebuilt binaries for Mac OS X currently have some serious problems, though.

As of February 2003, the latest posted version (7.1.3) was built with support for a command history in the interactive 'psql' interpreter using the up and down keys, and it includes the JDBC drivers (in /usr/local/pgsql/share/java). Unfortunately, this package is not currently compatible with Mac OS X 10.2.

Therefore, the other way to install PostgreSQL on Mac OS X is to download and install it from the source available at http://www.postgresql.org/. Select a mirror location close to you, and then download the source for the database project. In this instance, you'll use the postgres-7.2.3.tar.gz release.

Create a new user in the 'Users' System Preferences pane with the name 'PostgreSQL User', the short name 'postgres', and whatever password you want. Log out of Mac OS X, log back in as this user, and uncompress the postgres-7.2.3.tar.gz file in your ~/Documents directory.

Simple Database Software For Mac Os X

As noted in the MySQL section, using NetInfo to create a user without a home directory is a good security practice.

Then open the Terminal and execute the commands shown here from the new PostgreSQL installation directory:

This code fixes some issues in the sem.h file included with the distribution; these fixes are critical, so don't omit this step!

Next, comment out a few lines in the file Makefile.in , located in your installation's src/backend/port directory. If you have followed these instructions, the complete path to this file would be ~/Documents/postgresql-7.2.3/src/backend/port/Makefile.in. Use the # character to comment out the lines shown here:

The easiest way to do this from the command line is to use the pico text editor. You can search for this text and quickly find it using pico and the Control-W 'Where is' shortcut.

Finally, after making these fixes, you can compile and install the database:

Some of these commands can take time to execute (several minutes or more), and no user feedback will be provided.

You've now installed PostgreSQL on your system. When you're done, the resulting PostgreSQL installation is stored at /usr/local/pgsql, with the relevant PostgreSQL commands available at /usr/local/pgsql/bin.

12.2.2.2 Initializing PostgreSQL

Next, configure a test data set. Execute the following commands to initialize a database:

You're now running the PostgreSQL server, and any status information will be echoed to the console. Press Control-C in the terminal; this will cause PostgreSQL to shut down. If you haven't already, log out of the postgres user account and log back in with your regular account.

12.2.2.3 Starting PostgreSQL

Open a new Terminal window and execute the commands shown below to start PostgreSQL:

The su - postgres command lets you masquerade as the postgres user (you'll need to enter the postgres user's password as well), so you don't have to constantly log out and log in as different users. When you execute the postmaster command, the server's output will be sent to the ~/pgsql/log file.

PostgreSQL reports much of its information by using the STDERR output stream (not just STDOUT), and the >&~/pgsql/log sequence tells the shell to redirect output to a file instead of to these output streams. The final & tells the shell that this process should be run in the background.

You can monitor the output of this file by executing the command tail -501f~/pgsql/log:

12.2.2.4 Stopping PostgreSQL

You can shut the server down by executing the command ps to find the process ID (PID) of the postmaster process, which you can then terminate by issuing a killPID command, where PID is the postmaster process ID:

12.2.2.5 Creating a database

Now you can work with PostgreSQL data as a user. Make sure the database is running as described above. As the postgres user, execute the /usr/local/pgsql/bin/createuser command. Use your main account's short name from the 'System Preferences Accounts' dialog for the username, and allow database creation for new users.

Simple Database For Mac Os X

Next, open a new Terminal window and execute the createdb command to create your own database. You'll want to supply your own database name, of course:

12.2.2.6 Working with a database

Now you're ready to work with the psql program, an interactive SQL tool:

Use the name of the database you just created. You can use this program to enter SQL commands that execute directly against the database:

When you're done working in the psql shell, enter q and press return.

12.2.2.7 PostgreSQL JDBC configuration

To start working with PostgreSQL via JDBC, you will need the JDBC drivers available at http://jdbc.postgresql.org/download.html and the Postgres 7.2 JDBC 2 release (pgjdbc2.jar). To work with PostgreSQL, make sure that this file is on your classpath.

The driver name is org.postgresql.Driver, and the JDBC connection URL (which connects to the database you just created) is in the form jdbc:postgresql://127.0.0.1/databasename.

Best Database Software For Mac

12.2.3 Oracle 9i

Mac
12.2.1.5 Working with a database

Before issuing SQL commands to work with a database, log back in to the database:

After entering your password again, you'll see the mysql> prompt. To start working with the macjava database, type the following command:

You're now all set to begin adding tables, columns, and data to the database. To test this code, enter some SQL as shown:

To learn how to create tables and add sample data, see the next chapter.

12.2.1.6 MySQL JDBC configuration

You can download the MySQL JDBC driver (now known as Connector/J) from http://www.mysql.com/downloads/api-jdbc-stable.html (follow the links to a local mirror). Make sure the resultant JAR file (mysql-connector-java-2.0.14-bin.jar in my case) is on your classpath.

Bing For Mac Os X

If using Version 2.0.14 or later, you'll use com.mysql.jdbc.Driver as your driver class (prior releases used org.gjt.mm.mysql.Driver). The JDBC connection URL is in the form jdbc:mysql://127.0.0.1/databasename. Replace 127.0.0.1 with the hostname of your MySQL server, and you know what to do with databasename.

12.2.2 PostgreSQL

PostgreSQL is another popular open source database. Like MySQL, PostgreSQL is free, easy to run, and great for development work. While it doesn't offer a native installation for the Windows platforms, it is a little heavier-duty than MySQL, so it often finds a place in open source production environments.

12.2.2.1 Installation

The easiest way to install PostgreSQL is to download a prebuilt package from http://www.osxgnu.org/software/Database/postgresql/. PostgreSQL prebuilt binaries for Mac OS X currently have some serious problems, though.

As of February 2003, the latest posted version (7.1.3) was built with support for a command history in the interactive 'psql' interpreter using the up and down keys, and it includes the JDBC drivers (in /usr/local/pgsql/share/java). Unfortunately, this package is not currently compatible with Mac OS X 10.2.

Therefore, the other way to install PostgreSQL on Mac OS X is to download and install it from the source available at http://www.postgresql.org/. Select a mirror location close to you, and then download the source for the database project. In this instance, you'll use the postgres-7.2.3.tar.gz release.

Create a new user in the 'Users' System Preferences pane with the name 'PostgreSQL User', the short name 'postgres', and whatever password you want. Log out of Mac OS X, log back in as this user, and uncompress the postgres-7.2.3.tar.gz file in your ~/Documents directory.

Simple Database Software For Mac Os X

As noted in the MySQL section, using NetInfo to create a user without a home directory is a good security practice.

Then open the Terminal and execute the commands shown here from the new PostgreSQL installation directory:

This code fixes some issues in the sem.h file included with the distribution; these fixes are critical, so don't omit this step!

Next, comment out a few lines in the file Makefile.in , located in your installation's src/backend/port directory. If you have followed these instructions, the complete path to this file would be ~/Documents/postgresql-7.2.3/src/backend/port/Makefile.in. Use the # character to comment out the lines shown here:

The easiest way to do this from the command line is to use the pico text editor. You can search for this text and quickly find it using pico and the Control-W 'Where is' shortcut.

Finally, after making these fixes, you can compile and install the database:

Some of these commands can take time to execute (several minutes or more), and no user feedback will be provided.

You've now installed PostgreSQL on your system. When you're done, the resulting PostgreSQL installation is stored at /usr/local/pgsql, with the relevant PostgreSQL commands available at /usr/local/pgsql/bin.

12.2.2.2 Initializing PostgreSQL

Next, configure a test data set. Execute the following commands to initialize a database:

You're now running the PostgreSQL server, and any status information will be echoed to the console. Press Control-C in the terminal; this will cause PostgreSQL to shut down. If you haven't already, log out of the postgres user account and log back in with your regular account.

12.2.2.3 Starting PostgreSQL

Open a new Terminal window and execute the commands shown below to start PostgreSQL:

The su - postgres command lets you masquerade as the postgres user (you'll need to enter the postgres user's password as well), so you don't have to constantly log out and log in as different users. When you execute the postmaster command, the server's output will be sent to the ~/pgsql/log file.

PostgreSQL reports much of its information by using the STDERR output stream (not just STDOUT), and the >&~/pgsql/log sequence tells the shell to redirect output to a file instead of to these output streams. The final & tells the shell that this process should be run in the background.

You can monitor the output of this file by executing the command tail -501f~/pgsql/log:

12.2.2.4 Stopping PostgreSQL

You can shut the server down by executing the command ps to find the process ID (PID) of the postmaster process, which you can then terminate by issuing a killPID command, where PID is the postmaster process ID:

12.2.2.5 Creating a database

Now you can work with PostgreSQL data as a user. Make sure the database is running as described above. As the postgres user, execute the /usr/local/pgsql/bin/createuser command. Use your main account's short name from the 'System Preferences Accounts' dialog for the username, and allow database creation for new users.

Next, open a new Terminal window and execute the createdb command to create your own database. You'll want to supply your own database name, of course:

12.2.2.6 Working with a database

Now you're ready to work with the psql program, an interactive SQL tool:

Use the name of the database you just created. You can use this program to enter SQL commands that execute directly against the database:

When you're done working in the psql shell, enter q and press return.

12.2.2.7 PostgreSQL JDBC configuration

To start working with PostgreSQL via JDBC, you will need the JDBC drivers available at http://jdbc.postgresql.org/download.html and the Postgres 7.2 JDBC 2 release (pgjdbc2.jar). To work with PostgreSQL, make sure that this file is on your classpath.

The driver name is org.postgresql.Driver, and the JDBC connection URL (which connects to the database you just created) is in the form jdbc:postgresql://127.0.0.1/databasename.

Best Database Software For Mac

12.2.3 Oracle 9i

One important validation of Mac OS X has been its release of commercial database products for the platform. The database world still largely revolves around the folks at Oracle, so there is perhaps no more important database product for Mac OS X than a release of Oracle. Happily, it's now possible to download a developer version of Oracle 9i specifically tailored for use with Mac OS X 10.2 from http://otn.oracle.com/software/products/oracle9i/content.html. Click on the 'Take a Survey' link to register, and you can then download the software. If you're connecting to an existing Oracle 9i instance, you'll just need the JDBC drivers; otherwise, download the entire database for installation on your platform.

Oracle 9i is a very complex product, so if you're just starting to work with SQL databases, it is not the easiest place to begin. Beginning with MySQL or PostgreSQL is much easier.

Mac Os X Update

To get an idea of how complex Oracle is, note that the PostgreSQL 7.1.2 release is a little over 5 MB, whereas Oracle 9i weighs 345 MB. While a release's size isn't always indicative of its productivity, it usually says something about the complexity of the software involved.

Simple Database For Mac Os X64

For more information on Oracle 9i, and for guidelines on adopting it for your application development, read the overview at O'Reilly's MacDevCenter.com: http://www.macdevcenter.com/pub/a/mac/2002/11/12/oracle_part1.html. You should also check out Oraclein a Nutshell, by Rick Greenwald and David Kreines, and Java Programming with Oracle JDBC, by Donald Bales (both from O'Reilly).





broken image