Unix Databases

What can I use to setup a database? The main database available on our system is mSQL. It can be accessed via PHP (probably the most widely used method), MsqlPerl, or via the mSQL prompt via telnet (If you want to try this, get the mSQL docs first!). Some basics:

How do I do a quick and easy backup of my database? Use msqldump! Just follow these steps:

    Run the command msqldump databasename > filename.dump. This creates a flat ascii file with all of the commands necessary to totally recreate your mSQL database. (If you just run msqldump databasename without directing it to a file, then it echos to the screen! Yuck, yuck, phooey, phooey!)

    You can use this for a daily backup, delete or manipulate your tables, whatever. As long as you have this ascii file, you're OK.

    If you are experiencing problems with a table (key fields not working properly, spaces inserted into integers, etc.), then you can run an msqldump, delete the current structure, and feed the data back in with the command
    msql databasename < filename.dump. All better now!

Sample Msqldump for Database TEST

#
# mSQL Dump (requires mSQL-1.0.6 or better)
#
# Host: localhost Database: test
#--------------------------------------------------------


#
# Table structure for table 'TABLE01'
#
CREATE TABLE TABLE01 (
she CHAR(32),
him CHAR(32),
three CHAR(32)
) \g


#
# Dumping data for table 'TABLE01'
#

INSERT INTO TABLE01 VALUES ('Anna','Franz','Otto')\g
INSERT INTO TABLE01 VALUES ('Sabine','Thomas','Pauline')\g
INSERT INTO TABLE01 VALUES ('Jane','Paul','Jah')\g

#
# Table structure for table 'TABLE02'
#
CREATE TABLE TABLE02 (
she CHAR(32),
him CHAR(32),
three CHAR(32)
) \g


#
# Dumping data for table 'TABLE02'
#

INSERT INTO TABLE02 VALUES ('Anna','Franz','Otto')\g
INSERT INTO TABLE02 VALUES ('Sabine','Thomas','Pauline')\g
INSERT INTO TABLE02 VALUES ('Jane','Paul','Jah')\g

#
# Table structure for table 'TABLE03'
#
CREATE TABLE TABLE03 (
she CHAR(32),
him CHAR(32),
three CHAR(32)
) \g


#
# Dumping data for table 'TABLE03'
#

INSERT INTO TABLE03 VALUES ('Anna','Franz','Otto')\g
INSERT INTO TABLE03 VALUES ('Sabine','Thomas','Pauline')\g
INSERT INTO TABLE03 VALUES ('Jane','Paul','Jah')\g

#
# Table structure for table 'TABLE04'
#
CREATE TABLE TABLE04 (
she CHAR(32),
him CHAR(32),
three CHAR(32)
) \g


#
# Dumping data for table 'TABLE04'
#

INSERT INTO TABLE04 VALUES ('Anna','Franz','Otto')\g
INSERT INTO TABLE04 VALUES ('Sabine','Thomas','Pauline')\g
INSERT INTO TABLE04 VALUES ('Jane','Paul','Jah')\g

#
# Table structure for table 'TABLE05'
#
CREATE TABLE TABLE05 (
she CHAR(32),
him CHAR(32),
three CHAR(32)
) \g


#
# Dumping data for table 'TABLE05'
#

INSERT INTO TABLE05 VALUES ('Anna','Franz','Otto')\g
INSERT INTO TABLE05 VALUES ('Sabine','Thomas','Pauline')\g
INSERT INTO TABLE05 VALUES ('Jane','Paul','Jah')\g