#!/bin/sh # Copyright (C) 1997 TCX DataKonsult AB & Monty Program KB & Detron HB # For a more info consult the file COPYRIGHT distributed with this file # This scripts creates the privilige tables db, host, user in mysql # # All arguments to this script is passed to safe_mysqld if test ! -x /usr/local/bin/mysqladmin then echo "Can't execute /usr/local/bin/mysqladmin" exit 1 fi if test -f ~/mysql/mysql/db.ISM then echo "mysql privilege databases already installed. If you want to recreate all" echo "privilege tables, execute 'rm -i ~/mysql/mysql/*.IS?'" echo "and run this script again" echo echo "You can now start the new mysql server with:" echo "./safe_mysqld -l &" echo echo "Plese report any problems with the /usr/local/bin/mysqlbug script" exit 1 fi hostname=`hostname` # Install this too in the user table # create database mysql & test # if test ! -d ~/mysql ; then mkdir ~/mysql ; fi if test ! -d ~/mysql/mysql ; then mkdir ~/mysql/mysql ; fi if test ! -d ~/mysql/test ; then mkdir ~/mysql/test ; fi /usr/local/bin/mysqladmin ver > /dev/null 2>&1 if test $? -eq 0 then echo "The mysqld demon is already running. Stop it with" echo "'/usr/local/bin/mysqladmin shutdown' and try again." exit 1; else echo "Starting mysql server" ./safe_mysqld -Sg -l $* & while true do sleep 1 # This should be enough /usr/local/bin/mysqladmin ver > /dev/null 2>&1 if test $? -eq 0 ; then break; fi sleep 5 # This must be enough /usr/local/bin/mysqladmin ver > /dev/null 2>&1 if test $? -eq 0 ; then break; fi echo "System may be under load. Waiting for mysqld to start..." sleep 30 # Better safe than sorry /usr/local/bin/mysqladmin ver > /dev/null 2>&1 if test $? -eq 0 ; then break; fi echo "mysqld demon is not responding. Please try to start it manually with" echo "/usr/local/libexec/mysqld --skip-grant --log" echo echo "You can find some information about why it didn't start by examining" echo "the log file in the ~/mysql directory." echo echo "Remember to include the last few lines from the log file if you" echo "post a bug report about this. Please report bugs and ask questions" echo "with the /usr/local/bin/mysqlbug script!" echo "Before posting you should first check the reference manual," echo "section 'Problems with mysql_install_db' and then the MySQL" echo "mail archive if this is a common problem on your platform!" echo exit 1; done fi # copy the definition files # cp -p /scsi2/usr.local/share/mysql/mysql/*.frm ~/mysql/mysql /usr/local/bin/mysql mysql <<END_OF_DATA # Create tables from the .frm files # delete from db ; delete from host; delete from user; delete from func; # # Dumping data for table 'db' # INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y'); INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y'); # # Dumping data for table 'host' # INSERT INTO host VALUES ('localhost','%','Y','Y','Y','Y','Y','Y'); INSERT INTO host VALUES ('$hostname','%','Y','Y','Y','Y','Y','Y'); # # Dumping data for table 'user' # INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); INSERT INTO user VALUES ('localhost','','','N','N','N','N','N','N','N','N','N','N'); INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'); INSERT INTO user VALUES ('$hostname','','','N','N','N','N','N','N','N','N','N','N'); END_OF_DATA if test $? -eq 0 then /usr/local/bin/mysqladmin reload echo "mysqld demon is running and mysql grant tables are installed." echo echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !" echo echo "You can also try the mysql command line tool with:" echo "/usr/local/bin/mysql test" echo echo "Plese report any problems with the /usr/local/bin/mysqlbug script!" echo "The latest information about MySQL is available on the web at http://www.tcx.se" echo echo "Have fun and at least consider supporting MySQL if you find it useful :)" else echo "The grant tables was not installed. You should examine the log" echo "in ~/mysql for more information. You can also try to start" echo "the mysqld demon with --skip-grant and use the command line tool" echo "/usr/local/bin/mysql to connect to the mysql database and look at the" echo "grant tables:" echo echo "shell> /usr/local/bin/mysql -u root mysql" echo "mysql> show tables" echo echo "Starting mysqld with --help gives some information if you have problems" echo "with paths. Using --log gives you a log that may be helpful." echo echo "Plese report any problems with the /usr/local/bin/mysqlbug script!" echo "The latest information about MySQL is available on the web at http://www.tcx.se" fi