Thursday, December 16, 2010

Fast setup of a simple MySQL database on Solaris

This assumes that the MySQL software is installed already on your machine e.g. in /usr/sfw/bin on Solaris 10.

The recipe below will create a simple MySQL db on your machine in no time, of course it will be only accessible on your machine (the socket will be local), the data sit in your home directory but it suffices to get a simple db to play with.

The initial setup is easy.
  • Choose a directory e.g. $HOME/mydata where to put the db.
  • Choose a socket e.g. /tmp/my.$USER.sock for the server/client connection.

In a Bourne or Korn shell these 4 commands get the db going:
/usr/sfw/bin/mysql_install_db  --datadir=$DATADIR
/usr/sfw/sbin/mysqldb &
and then run the following to connect to the db (like isql in Sybase):
will get you a prompt , do
use test;
which will connect you to the 'test' db and
create table aa (bb int);
will create a table 'aa' with one column 'bb' of type integer.

For more details the use the online ref

Have fun, MySQL has a huge number of tuning possibilities, not necessarily though for the beginner or for simple small dbs.

Note: this article was written in 2007 when MySQL 5.0 was hot, I haven't checked with later releases, in particular after Oracle has taken on Sun Microsystems which had acquired MySQL earlier.

No comments:

Post a Comment