2002-08-16 09:24:08 +08:00
<sect2 >
2003-09-29 06:10:55 +08:00
<title > Configuring <application > My<acronym > SQL</acronym> </application> </title>
2002-08-16 09:24:08 +08:00
<sect3 >
<title > Config files</title>
2003-04-21 06:15:01 +08:00
<para > <filename > /etc/my.cnf</filename> , <filename > ~/.my.cnf</filename> </para>
2002-08-16 09:24:08 +08:00
</sect3>
<sect3 >
<title > Configuration Information</title>
<para > There are several default configurations file available in
2003-09-07 22:14:01 +08:00
<filename class= "directory" > /usr/share/mysql</filename> which you can use.</para>
2002-08-16 09:24:08 +08:00
2004-01-13 01:55:49 +08:00
<screen > <userinput > <command > cp /usr/share/mysql/my-medium.cnf /etc/my.cnf</command> </userinput> </screen>
2002-08-16 09:24:08 +08:00
<para > We can now install a database and change the ownership to the
2003-10-04 00:43:11 +08:00
unprivileged user and group.</para>
2002-08-16 09:24:08 +08:00
2004-01-13 01:55:49 +08:00
<screen > <userinput > <command > mysql_install_db & &
2003-09-07 22:14:01 +08:00
chown -R mysql:mysql /var/lib/mysql</command> </userinput> </screen>
2002-08-16 09:24:08 +08:00
<para > Further configuration requires that the mysql server be running:</para>
2004-01-13 01:55:49 +08:00
<screen > <userinput > <command > mysqld_safe --user=mysql 2> & 1 > /dev/null & </command> </userinput> </screen>
2002-08-16 09:24:08 +08:00
2003-12-14 01:21:42 +08:00
<para > A default installation does not setup a password for the administrator
so here we will set one. Replace <replaceable > [new-password]</replaceable>
with your own.</para>
2002-08-16 09:24:08 +08:00
2003-12-14 01:21:42 +08:00
<!--
2003-09-30 11:14:19 +08:00
<screen > <userinput > <command > mysql -uroot mysql</command> </userinput>
2002-08-16 09:24:08 +08:00
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 3.23.51-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
2003-09-30 11:14:19 +08:00
<prompt > mysql> </prompt> <userinput > <command > UPDATE user SET password=password('<replaceable > new-password</replaceable> ') WHERE user='root';</command> </userinput>
2002-08-16 09:24:08 +08:00
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
2003-09-30 11:14:19 +08:00
<prompt > mysql> </prompt> <userinput > <command > FLUSH PRIVILEGES;</command> </userinput>
2002-08-16 09:24:08 +08:00
Query OK, 0 rows affected (0.00 sec)
2003-09-30 11:14:19 +08:00
<prompt > mysql> </prompt> <userinput > <command > EXIT;</command> </userinput>
2002-08-16 09:24:08 +08:00
bye
2003-09-30 11:14:19 +08:00
</screen>
2003-12-14 01:21:42 +08:00
-->
2003-12-14 01:37:20 +08:00
<screen > <userinput > <command > mysqladmin -u root password <replaceable > [new-password]</replaceable> </command> </userinput> </screen>
2002-08-16 09:24:08 +08:00
<para > Now that we are done with the configuration of the server, we can
shut it down.</para>
2004-01-04 07:25:37 +08:00
<screen > <userinput > <command > mysqladmin -p shutdown</command> </userinput> </screen>
2002-08-16 09:24:08 +08:00
2003-09-29 06:10:55 +08:00
<para > To automate the running of <application > My<acronym > SQL</acronym> </application> , use the following command to create
2002-08-16 09:24:08 +08:00
the init.d script:</para>
2003-09-29 21:41:12 +08:00
<screen > <userinput > <command > cat > /etc/rc.d/init.d/mysql < < "EOF"</command>
2002-08-16 09:24:08 +08:00
#!/bin/bash
# Begin $rc_base/init.d/
# Based on sysklogd script from LFS-3.1 and earlier.
# Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
source /etc/sysconfig/rc
source $rc_functions
2004-01-04 07:25:37 +08:00
pid_file=/var/lib/mysql/`/bin/hostname`.pid
2002-08-16 09:24:08 +08:00
case "$1" in
start)
echo "Starting MySQL daemon..."
2004-01-11 00:03:56 +08:00
failure=0
if test -f "$pid_file"
then
if /bin/ps p `cat $pid_file` | grep mysqld > /dev/null
then
print_status warning running
2004-01-12 03:14:34 +08:00
exit 0
2004-01-11 00:03:56 +08:00
else
rm -f $pid_file
if test -f $pid_file
then
failure=1
fi
fi
fi
if [ $failure = 1 ]
then
2004-01-12 03:14:34 +08:00
print_status failure
2004-01-04 07:25:37 +08:00
else
2004-01-04 08:07:14 +08:00
/usr/bin/mysqld_safe --user=mysql 2> & 1 > /dev/null &
2004-01-04 07:25:37 +08:00
evaluate_retval
fi
2002-08-16 09:24:08 +08:00
;;
stop)
echo "Stopping MySQL daemon..."
2004-01-04 07:25:37 +08:00
if test -s "$pid_file"
then
kill `cat $pid_file`
sleep 1
failure=0
while [ -s $pid_file -a "$flags" != aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ]
do
[ -z "$flags" ]
flags=a$flags
sleep 1
done
if [ -s $pid_file ]
then failure=1
fi
(exit $failure)
evaluate_retval
else
print_status warning not_running
fi
2002-08-16 09:24:08 +08:00
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
statusproc /usr/sbin/mysqld
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
# End $rc_base/init.d/
2003-09-29 21:41:12 +08:00
<command > EOF
2003-09-07 22:14:01 +08:00
chmod 755 /etc/rc.d/init.d/mysql</command> </userinput> </screen>
2002-08-16 09:24:08 +08:00
2003-04-22 11:06:28 +08:00
<para > Create the symbolic links to this file in the relevant
2003-09-07 22:14:01 +08:00
<filename class= "directory" > rc.d</filename> directory
2002-08-16 09:24:08 +08:00
with the following commands:</para>
2003-09-07 22:14:01 +08:00
<screen > <userinput > <command > cd /etc/rc.d/init.d & &
2002-08-16 09:24:08 +08:00
ln -sf ../init.d/mysql ../rc0.d/K26mysql & &
ln -sf ../init.d/mysql ../rc1.d/K26mysql & &
ln -sf ../init.d/mysql ../rc2.d/K26mysql & &
ln -sf ../init.d/mysql ../rc3.d/S34mysql & &
ln -sf ../init.d/mysql ../rc4.d/S34mysql & &
ln -sf ../init.d/mysql ../rc5.d/S34mysql & &
2003-09-07 22:14:01 +08:00
ln -sf ../init.d/mysql ../rc6.d/K26mysql</command> </userinput> </screen>
2002-08-16 09:24:08 +08:00
2003-12-14 01:21:42 +08:00
<para > Finally, add this entry to your <filename > ld.so.conf</filename>
file so that programs which utilize
<application > My<acronym > SQL</acronym> </application> can find its
libraries:</para>
<screen > <userinput > <command > echo /usr/lib/mysql > > /etc/ld.so.conf</command> </userinput> </screen>
2002-08-16 09:24:08 +08:00
</sect3>
</sect2>