home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 January / Chip_2001-01_cd1.bin / tema / mysql / mysql-3.23.28g-win.exe / DATA1.CAB / Help_Files / Docs / mysql-for-dummies < prev   
Text File  |  2000-11-22  |  11KB  |  272 lines

  1. ===============================================================================
  2. installing/mysql/binary        Fri Jul 17 13:03:03 1998        has
  3. ===============================================================================
  4.  
  5.                  MySQL for dummies - Part 1
  6.     How to get the binary distribution running on a UNIX system
  7.  
  8.                MySQL is a trademark of TcX, Sweden.
  9.  
  10. ===============================================================================
  11.  
  12. Introduction:
  13.  
  14. This is a simple cookbook for the helpless newbie taking his very first steps
  15. with MySQL, when he needs a few hints about the options and access rights
  16. installing the system and starting the basic modules, before he has "aha"ed
  17. on how simple and clean the basic structure of MySQL is.  It will not help
  18. you with the intricacies and subtle possibilities of SQL as implemented in
  19. MySQL.
  20.  
  21. The information in this document is all contained in the MySQL manual in a
  22. more or less obvious form, but for the newbie that document is a bit over-
  23. whelming in size, and it contains some new concepts that take some getting
  24. used to.  Sorry if it is pitched too low for some readers.  It is only
  25. intended to get the binary distribution up and running.
  26.  
  27. I successfully got MySQL going on both a Sun SparcStation 1 running SunOS 4.1.2
  28. and 2 Linux systems running SuSE release 5.0, one with kernel version 2.0.30,
  29. one with 2.0.33 by doing exactly what is given here.  If it doesn't work
  30. for you, I suggest the problem is with your system and not with the 
  31. MySQL binary distribution.
  32.  
  33. -- Howard Schultens     hs@neuro-physiol.med.uni-goettingen.de
  34.  
  35. -------------------------------------------------------------------------------
  36.  
  37. Nomenclature:
  38.  
  39. In the following, 'MySQL' refers to the entire database system distributed
  40. and licensed by TcX. 'mysql' means a specific program in this system.
  41.  
  42. -------------------------------------------------------------------------------
  43.  
  44. MySQL user administration and access rights ("privileges"):
  45.  
  46. It is obvious that MySQL needs its own user management because it is a system
  47. that is implemented on a number of architectures -- you should be able to use
  48. it in an identical way on different operating systems.  The MySQL user names
  49. and passwords have basically nothing at all to do with user names and
  50. passwords on whatever operating system you install it on.  You will,
  51. unfortunately, have to install your users again on MySQL.  But this system has
  52. some big advantages: it is a secure system that allows you to finely
  53. differentiate access rights based on WHO is using a database from WHERE.  It
  54. does this by the use of its own database containing 3 tables "user" for the
  55. user names, "db" for the databases, and "host" for the machines that access
  56. databases. "user" and "db" are the most important for the newbie.
  57.  
  58. Section 6 of the manual describes all this in detail.
  59.  
  60. -------------------------------------------------------------------------------
  61.  
  62. Doing it:
  63.  
  64. In the following, "foo>" denotes the prompt from your system in user mode,
  65. "foo#" as root/superuser.
  66.  
  67.  
  68. 1) Get the appropriate binary distribution from a mirror site or directly
  69.    from TcX at URL http://www.tcx.se. The file name has the form
  70.     mysql-VERSION-SYSTEM.tgz
  71.  
  72.     VERSION = Version number, e.g. 3.21.33
  73.     SYSTEM  = OS and architecture, e.g. sunos4.1.4-sparc
  74.  
  75.    i.e., you would download a file mysql-3.21.33-sunos4.1.4-sparc.tgz.
  76.  
  77.    This example is for SunOS, but it works exactly analogously on Linux.
  78.  
  79. 2) cd to /usr/local and unpack this with, e.g. the command
  80.  
  81.     foo#gzip -c -d mysql-VERSION-SYSTEM.tgz|tar xvf -
  82.  
  83. 3) The files are stored in a directory /usr/local/mysql-VERSION-SYSTEM
  84.    Make a symbolic link to this directory:
  85.  
  86.     foo#ln -s mysql-VERSION-SYSTEM mysql
  87.  
  88.    At this point, you might want to create a special user for all your
  89.    MySQL stuff.  I use "mysql".  Then you could do
  90.  
  91.     foo#chown -R mysql mysql-VERSION-SYSTEM
  92.  
  93. 4) FIRST, take care of all the PERL stuff:
  94.  
  95.   o)  You need PERL 5.004 or later already installed on your system.  Take
  96.       care of this first if necessary.
  97.  
  98.   a)  cd to /usr/local/mysql/perl/DBI and do
  99.     foo#perl Makefile.PL
  100.         foo#make
  101.         foo#make test
  102.         foo#make install        (if "make test" is successful)
  103.  
  104.   b)  cd to /usr/local/mysql/perl/Mysql/modules and do
  105.     foo#perl Makefile.PL
  106.         foo#make
  107.         foo#make test
  108.         foo#make install        (if "make test" is successful)
  109.  
  110.   c)  As an option, you can install Data::ShowTable, but this is not absolutely
  111.       necessary for mysql.  Get the PERL module Data-ShowTable-VER.tar.gz
  112.       (VER = version, eg. 3.3) from a CPAN mirror: I got mine at
  113.    
  114.       ftp://ftp.gwdg.de/pub/languages/perl/CPAN/modules/by-category/06_Data_Type_Utilities/Data/Data-ShowTable-3.3.tar.gz
  115.  
  116.       (You should be able to replace "ftp.gwdg.de" by the name of another
  117.        FTP mirror)
  118.  
  119.  Put this into /usr/local/mysql/perl and unpack it.
  120.       You get a directory 'Data-ShowTable-VER'.  cd into there and 
  121.       (as root/superuser)
  122.     foo#perl Makefile.PL
  123.         foo#make
  124.         foo#make test
  125.         foo#make install        (if "make test" is successful)
  126.  
  127. 5) cd to /usr/local/mysql and do
  128.     foo#scripts/mysql_install_db
  129.  
  130.    you should be in /usr/local/mysql when you start the script.
  131.  
  132. ==>*NOTE* you might want to edit this script before you run it the first
  133.    time.  See method 9b) below.
  134.  
  135.    If this is successful, one or more copies of the mysql daemon, mysqld,
  136.    will be running.  On SunOS 4.1.x, you get one.  On Linux, 3 are running.
  137.  
  138. -------------------------------------------------------------------------------
  139. In the rest of this, I will always suppose you are starting in the directory
  140. /usr/local/mysql, even if it seems mildly inconvenient
  141. -------------------------------------------------------------------------------
  142.  
  143. 6) You can now select the database 'test' and mess around with it using
  144.    the client program bin/mysql:  start it with
  145.  
  146.     foo>bin/mysql -u root test
  147.  
  148.    This says, "start up the MySQL command-line client with the user name
  149.    'root' and use the database named 'test', which is a subdirectory in
  150.    '/usr/local/mysql/data". (n.b. this is NOT the root user of your UNIX
  151.    system, it is a MySQL user with the same name. You will notice that you
  152.    don't need a password for this user to use mysql).
  153.  
  154.    Actually, the way the system is set up by bin/mysql_install_db, you
  155.    don't even need a user name to access the database 'test'.  You can start
  156.    the client simply with
  157.  
  158.     foo>bin/mysql test
  159.  
  160.    'mysql' should start up with a greeting and a line telling you what your
  161.    connection id and server version is.  At this point, the database 'test'
  162.    is empty, no tables or anything are defined.
  163.    
  164.    When you issue SQL commands, DON'T FORGET THE FINAL SEMICOLON, or mysql acts
  165.    dumb:
  166.  
  167.     mysql>select * from user
  168.             ->
  169.             ->
  170.  
  171.    and you wonder what's going on. 'mysql' reminds you of this on startup.
  172.  
  173. 7) When you want to close down the server, do
  174.     foo>bin/mysqladmin shutdown
  175.  
  176. 8) I recommend editing the script bin/safe_mysqld for the binary release
  177.    so that it always starts up with the correct directories.  I replaced
  178.    the entire header up to but not including
  179.  
  180.    pidfile=$DATADIR/`/bin/hostname`.pid
  181.    log=$DATADIR/`/bin/hostname`.log
  182.    err=$DATADIR/`/bin/hostname`.err
  183.  
  184.    with
  185.  
  186.    MY_BASEDIR_VERSION=/usr/local/mysql
  187.    DATADIR=$MY_BASEDIR_VERSION/data
  188.    ledir=$MY_BASEDIR_VERSION/bin
  189.    cd $MY_BASEDIR_VERSION
  190.  
  191.    This lets you start the mysql daemon from wherever you like.
  192.  
  193. 9) Now let's say you want to put some of your own databases and users into
  194.    the system.  The simplest, most powerful, and dangerous way to do this is
  195.    to start up the mysql daemon again with:
  196.  
  197.     foo>bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data -Sg
  198.  
  199.    This skips loading the grant tables.  The system is open to every kind of
  200.    mistake now, so be careful.  Any user can muck up the grant tables, ie.
  201.    the lists of users, hosts, and databases themselves, so only use this
  202.    mode to do these first, very basic things.
  203.  
  204.    Start the client again now, with
  205.     foo>bin/mysql mysql
  206.  
  207.    This tells the client to use the database 'mysql', which is the directory
  208.    that contains the lists (ie. the tables) of all the users, hosts, and 
  209.    databases in the system, so be careful!!!!!!!!!!!!
  210.  
  211.    All of what follows is taken essentially from section 6 of the manual.
  212.  
  213.    a) For the start, just define a couple of users for the MySQL system:
  214.       i) an administrator, such as 'mysql', with its own password, that
  215.          can do everything with the system:
  216.  
  217.      mysql> insert into user values('localhost','mysql',password('xyzzy'),
  218.         'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
  219.  
  220.      * For some reason, on my Linux system with a German keyboard, I have *
  221.          * to use the acute accent instead of the apostrophe, otherwise I get *
  222.      * parse errors.                                                      *
  223.  
  224.      This defines the user name 'mysql' with password 'xyzzy' that can
  225.      do everything. To look at what you just did, type in
  226.  
  227.          mysql> select * from user;
  228.  
  229.      mysql types out a table with all the known users and their privileges.
  230.  
  231.        ii) a privileged user for playing around:
  232.  
  233.      mysql> insert into user values('localhost','john',password('blah0x1'),
  234.         'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
  235.  
  236.        iii) create your own database for a todo list, phone numbers, whatever:
  237.  
  238.      mysql> create database johns_DB;
  239.      mysql> insert into db values('localhost','johns_DB','john','Y','Y','Y','Y','Y','Y');
  240.  
  241.      The first line creates the databse "johns_DB", but that doesn't
  242.      make it visible to mysql.  The second line does that.
  243.  
  244.     iv) When you are done installing users and databases, quit mysql and
  245.             issue the command
  246.  
  247.         foo>bin/mysqladmin reload
  248.  
  249.     b) Another method to do this was suggested by Sinisa Milivojevic, and that
  250.        is to edit the script /usr/local/mysql/scripts/mysql_install_db to
  251.        define the databases and install the more important users when you
  252.        start the system the very first time.  This would have the advantage
  253.        that you can save the script and re-install the system with it if you
  254.        have to, automatically defining the important structures.  It requires
  255.        a little more knowledge of the MySQL system to do this.
  256.  
  257.        You might want to use this method anyway since it saves editing
  258.        mysql_install_db to have it install a superuser with a name other
  259.        than "root".  The places to change are easy to find. You can, of
  260.        course, use the first method above and remove the user named 'root'
  261.        when you are done.
  262.  
  263.  
  264. ===============================================================================
  265.  
  266. If anyone is interested enough in this document to make suggestions on how
  267. to improve it, I would be glad to get emails on it.  I hope it helps
  268. someone get going with MySQL a little easier.
  269.  
  270. --Howard
  271.   hs@neuro-physiol.med.uni-goettingen.de
  272.