Skip to main content

Getting Started with MySQL (part 1)

posted onMay 16, 2001
by hitbsecnews

By: L33tdawg

I was sitting around the other day contemplating what to write for this issue, and it struck me that as of late, I've been getting asked
quite often about SQL syntax but more importantly how to get it installed on a *NIX machine. Most times I just tell people to go do a search on
the net and they're bound to find enough help documents to write a book - but considering that many are just plain lazy and expect to be given an
absolute URL where they can find the information they need, I decided perhaps I'll just write up a short piece on this nifty little database
application. Who knows, I might just even hook you guys up with a few simple SQL syntax to get everyone started. *grin*. Note: This article isn't
intended to replace or supplement a good book or HOW-TO document on installing and configuring SQL, but its merely yet another referencing point
for the uninitiated to read and digest in their quest for knowledge - *lol* That was certainly a mouthful. Okay i'm rambling - lets get started.

Installation

Obviously the first thing you're going to need is the MySQL binary
files. Open up your favourite web browser and head on over to
http://www.mysql.com -- yes I know, it's an open source application and
frankly I would have headed to .org by default as well, but its .com -- at the time of writing this article, the latest version of MySQL is 3.23 -- now while
I usually recommend people to download the stable releases, the
development team of the project are quite conservative when it comes to
naming their releases, and I think you'd find that even Gamma or Beta
releases will work fine. If however you're planning on implementing MySQL
on a production level machine, perhaps it would be best to go with the
stable release -- just incase.

Once you've grabbed your copies, the first thing you'll need to do is su
to root and add in a user group for the sql daemon - while this isn't
explicitly neccesary, it's quite pointless having the daemon run as root
when it doesn't need to. To do this simple perform the following:

groupadd mysql
useradd -U mysql mysql

unpack the mysql package with the usual

tar -xvzf mysql-3.22.32.tar.gz

in the directory of your choice. You'll then need to run the configure
script. Most times, MySQL is installed in /usr/local/mysql/ so just run
the following :

./configure --PREFIX=/usr/local/mysql

followed by the make and make install commands.

After that's done you'll need to run the script to creat the default
databases. For the purpose of this article, we'll be using the
mysql_install_db script which you can execute by performing the following:

script/mysql_install_db

You'll now need to change the ownership of the newly created MySQL
directory to the mysql user we created earlier.

chown -R mysql.mysql /usr/local/mysql

It's finally time to get start the database server.

/usr/local/mysql/bin/safe_mysqld --user=mysql &

If something doesn't go quite right, just excamine the contents of the
/usr/local/mysql/var -- for the curious ones out there, safe_mysqld is
nothing more than a shell script that launches the server process
mysqld. Before moving to anything else, it would be a good idea to change
the root password for the database.

/usr/local/mysql/bin/mysqladmin -u root password new-password

(where password is the current root password set and new-password is well,
a new password). Do take note that MySQL does not make use of the UNIX
usernames and passwords -- every user wanting to gain access to the SQL
database must be listed in MySQL's internal database.

Logging in

To log into just issue the following command:

/usr/local/mysql/bin/mysql -u root -p

You'll be prompted to enter your root user password after hitting the
Enter key. You can put the password on the command line if you don't feel
like typing it in after issueing the command, but do take note that you'll
need to exclude a space between the -p flag and the password
(e.g. /usr/local/mysql/bin/mysql -u root -prootpassword)

Congratulations! You now have a fully functioning MySQL server up and
running. It's now a pretty good idea to set-up the MySQL server to start
up at boot time. The simplest way to do this (on RH and SYSV-R4 type
systems is to copy the file mysql-3.23.xx/support-files/mysql.server to
/etc/init.d. Next symbolically link it to s99mysql into /etc/rc.d/rc3.d
and s01mysql to /etc/rc.d/rc0.d as follows :

ln -s /etc/init.d/mysql.server /etc/rc.d/rc3.d/S99mysql
ln -s /etc/init.d/mysql.server /etc/rc.d/rc0.d/S0mysql

You'll need to make the /etc/rc.d/init.d/mysql.server file executable (its
not by default)... just chmod 755 /etc/rc.d/init.d/mysql.server

Note: Due to time constraints, I am going to have to end off here for this
month, and continue on with server configuration and security issues to
keep in mind with SQL and perhaps a sample PERL script in the next
issue. Till then, have fun, and stay out of trouble.

Peace.
L33tdawg.

1.) Remote Host Discovery with Portscanning - adept
2.) Script Kiddies and Screenwhores - Grifter
3.) Intro to Packet Sniffers - Grifter
4.) Quantum Mechanics (Part 2) - Josette
5.) SWATing Samba - socrates
6.) The Quest for Passwords - Shaft
7.) Windows or Linux? - Sebastian
8.) Getting Started with MySQL - L33tdawg

Source

Tags

Intel

You May Also Like

Recent News

Friday, November 29th

Tuesday, November 19th

Friday, November 8th

Friday, November 1st

Tuesday, July 9th

Wednesday, July 3rd

Friday, June 28th

Thursday, June 27th

Thursday, June 13th

Wednesday, June 12th

Tuesday, June 11th