starting with mysql

merlin's picture

They have: 410 posts

Joined: Oct 1999

i'd like to start with mysql these days. now, how do i do that? what are the first steps?

my configuration:
- win NT
- perl 5.005
- apache-server as localhost

i'd just like to start relaxed: some trial & error with the db, final destination: web-pages based on perl and mysql.

what i did until now:
- downloaded 'mysql-3_23_27-beta-win.zip' from http://www.mysql.org
- installed mysql over normal setup-routine
what i did without knowing what i'm exactly doing:
- starting mysql as a service
- tried 'mysqlshow' and got an error message (can't connect to localhost).

anyway, am i going the right way?

They have: 334 posts

Joined: Dec 1999

I've never tried MySQL on NT, only on Win98, but it should be similar. Do a ctrl+alt+delete to see if MySQL is actually running. If it's not, you need to start it before mysqlshow or any other commands will work. So, from a DOS command line in the c:\mysql\bin directory (or wherever you installed MySQL) you need to run 'mysqld' or 'mysqld-shareware' or whatever the main .exe file is named these days. Once that starts up 'mysqlshow' should work.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Like Maverick, I've only done it on a win98.

You might want to get PHP installed and then put phpMyAdmin on there. You don't need to know any php to use it, and it really helps you with DB stuff. I use it alot when I'm developing with mySQL.

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 11 posts

Joined: Jul 2000

I use mySQL on NT...the first step I would recommend taking after doing what you have done is to check the service is started...there should be a traffic lights icon in the System Tray. If not then you need to run the "winmysqladmin.exe" file in the mySQL folder. That should load a windows based mySQL-admin/status tool.
From there you can make sure its started.
Then you need to run "mysql.exe" within the mysql/bin folder - there you can issue sql statements like SELECT ...
But I also recommend installing PHP and phpMyAdmin...its the best way to make tables and databases etc without learning all of teh commands Smiling

merlin's picture

They have: 410 posts

Joined: Oct 1999

ok, thank you!
i'll go and get php/phpmyadmin and probably i come back with some new probs... Wink
thanks a lot!

merlin's picture

They have: 410 posts

Joined: Oct 1999

ok, i got it running, downloaded php and phpmyadmin. so, what's next?
i suppose i'll go and get a book 'bout mysql (my favourites are the ones by o'reilly)?
but until i got the book, could you tell me some basic statements (like building a table, ...)?

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

sure...

this is a dump from a DB on my win98 mySQL server, you can probably figure out what's going on, if not, just ask.
(this dump is from phpMyAdmin Laughing out loud)
(the DB is for a poll script I made. It need beta testing if anyone is interested.)

Database Poll
# phpMyAdmin MySQL-Dump
# <a href="http://phpwizard.net/phpMyAdmin/" class="bb-url">http://phpwizard.net/phpMyAdmin/</a>
#
# Host: localhost Database : Poll

# --------------------------------------------------------
#
# Table structure for table 'GaminConsols'
#

CREATE TABLE GaminConsols (
   Id int(11) NOT NULL auto_increment,
   Question blob NOT NULL,
   A1 blob NOT NULL,
   R1 int(5) NOT NULL,
   A2 blob NOT NULL,
   R2 int(5) NOT NULL,
   A3 blob NOT NULL,
   R3 int(5) NOT NULL,
   A4 blob NOT NULL,
   R4 int(5) NOT NULL,
   A5 blob NOT NULL,
   R5 int(5) NOT NULL,
   PRIMARY KEY (Id)
);

#
# Dumping data for table 'GaminConsols'
#

INSERT INTO GaminConsols VALUES( '1', 'Which gaming consols do you own?', 'N 64', '18', 'Playstation 2', '9', 'DreamCast', '10', 'GameBoy', '13', 'NeoGeo', '8');

# --------------------------------------------------------
#
# Table structure for table 'RightyLefty'
#

CREATE TABLE RightyLefty (
   Id int(11) NOT NULL auto_increment,
   Question blob NOT NULL,
   A1 blob NOT NULL,
   R1 int(5) NOT NULL,
   A2 blob NOT NULL,
   R2 int(5) NOT NULL,
   PRIMARY KEY (Id)
);

#
# Dumping data for table 'RightyLefty'
#

INSERT INTO RightyLefty VALUES( '1', 'Are you a Righty or a Lefty?', 'Righty', '267', 'Lefty', '183');

# --------------------------------------------------------
#
# Table structure for table 'pollformat'
#

CREATE TABLE pollformat (
   Id int(11) NOT NULL auto_increment,
   FormatName blob NOT NULL,
   QBegin blob,
   QEnd blob,
   ABegin blob,
   AEnd blob,
   VoteText blob,
   ViewText blob,
   VoteSrc blob,
   ViewSrc blob,
   Type varchar(7),
   DateBegin blob,
   DateEnd blob,
   TotalBegin blob,
   TotalEnd blob,
   VotesBegin blob,
   VotesEnd blob,
   Size blob,
   Ordering blob,
   BarSrc blob,
   BarHeight blob,
   AllowView blob,
   PRIMARY KEY (Id)
);

#
# Dumping data for table 'pollformat'
#

INSERT INTO pollformat VALUES( '1', 'Archive', '', '', '', '', '', '', '', '', 'archive', '', '', '', '', '>', '', '', '', '', '', '');
INSERT INTO pollformat VALUES( '2', 'BoldQ', '<font size=4><b><u>', '</u></b></font>', '<font size=2>', '</i></font>', 'Vote!', 'View Results', '', '', 'button', '', '', '', '', '<font size=2 face=verdana>', '</font>', '100', 'default', 'your.gif', '10', 'no');
INSERT INTO pollformat VALUES( '3', 'OtherOne', '<b><i>', '</i></b>', '<font size=2><i>', '</i></font>', 'Vote!', 'View Results', 'yourvote.gif', 'yourview.gif', 'image', '', '', '<b>', '</b>', '<br><font size=2 face=verdana>', '</font>', '150', 'votesasc', 'your.gif', '20', 'yes');

# --------------------------------------------------------
#
# Table structure for table 'pollip'
#

CREATE TABLE pollip (
   Id int(11) NOT NULL auto_increment,
   RightyLefty blob,
   GaminConsols blob,
   PRIMARY KEY (Id)
);

#
# Dumping data for table 'pollip'
#

INSERT INTO pollip VALUES( '1', '127.0.0.1', '');
INSERT INTO pollip VALUES( '2', '', '');
INSERT INTO pollip VALUES( '3', '', NULL);
INSERT INTO pollip VALUES( '4', '', NULL);
INSERT INTO pollip VALUES( '5', '', NULL);
INSERT INTO pollip VALUES( '6', '', NULL);
INSERT INTO pollip VALUES( '7', '', NULL);
INSERT INTO pollip VALUES( '8', '', NULL);
INSERT INTO pollip VALUES( '9', '', NULL);
INSERT INTO pollip VALUES( '10', '', NULL);

# --------------------------------------------------------
#
# Table structure for table 'pollprefs'
#

CREATE TABLE pollprefs (
   Id int(11) NOT NULL auto_increment,
   IPignore blob,
   myIP blob,
   numIP blob,
   UserName blob,
   Cookies blob,
   QBegin blob,
   QEnd blob,
   ABegin blob,
   AEnd blob,
   VoteText blob,
   ViewText blob,
   VoteSrc blob,
   ViewSrc blob,
   Type varchar(7),
   DateBegin blob,
   DateEnd blob,
   TotalBegin blob,
   TotalEnd blob,
   VotesBegin blob,
   VotesEnd blob,
   Size blob,
   Ordering blob,
   BarSrc blob,
   BarHeight blob,
   AllowView blob,
   numAnswers blob,
   PollStyle blob,
   PRIMARY KEY (Id)
);

#
# Dumping data for table 'pollprefs'
#

INSERT INTO pollprefs VALUES( '1', 'off', '', '10', 'your.com', 'on', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '2', 'R');

# --------------------------------------------------------
#
# Table structure for table 'polls'
#

CREATE TABLE polls (
   Id int(11) NOT NULL auto_increment,
   Status enum('N','O','C') DEFAULT 'N' NOT NULL,
   TableName varchar(25) NOT NULL,
   Style enum('C','R') DEFAULT 'R' NOT NULL,
   PRIMARY KEY (Id),
   UNIQUE TableName (TableName)
);

#
# Dumping data for table 'polls'
#

INSERT INTO polls VALUES( '1', 'O', 'RightyLefty', 'R');
INSERT INTO polls VALUES( '2', 'N', 'GaminConsols', 'C');
'

PS - sorry for stretching the screen Shocked

Mark Hensler
If there is no answer on Google, then there is no question.

merlin's picture

They have: 410 posts

Joined: Oct 1999

after some reading (php-docs) and hacking (apache-conf, why can't php do that automatically? anyway, i learned something... Wink ) i got it (phpmyadmin) working...
after playing around i have a very basic question, i didn't find the answer in my smart book (mysql & msql, o'reilly):
i have a field called 'CD_ID', defined as auto-increment. now, when i'm inserting a row, i have to state a value into this field. i tried it with nothing, but that's only working the first time... Wink
i'm sure the answer is pretty easy... thank you!

They have: 334 posts

Joined: Dec 1999

No, you don't need to insert a value into that field. An auto_increment field doesn't need to have anything added to it and works properly with NULL. It's kind of like a counter. When the rest of the columns in that row are added, the auto_increment column just ratchets upward to be one higher than the highest value in the column.

If it's not working properly, check first to see if it's set an an int column, not as a char or varchar since it'll be storing numbers. It should also be set as a PRIMARY KEY or UNIQUE and make sure there's only one auto_increment column in the table. And also, set it as NOT NULL. It won't ever be NULL because it gets added even when you don't insert a value, it's just good form Wink

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

ali,

Maverick is correct, with an auto-increment or Identity field you do not insert any values into it, the database handles that. The only thing you can do with that field is tell it how much to increment by, this usually defaults to 1, so that with each new record it goes 1,2,3 etc. but you can set this to another number, 5 for example, then it would go 5,10,15 etc.

PJ | Are we there yet?
pjboettcher.com

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.