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
2003-09-07 22:14:01 +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
unpriviledged user and group.</para>
2003-09-07 22:14:01 +08:00
<screen > <userinput > <command > mysql_install_db
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>
2003-09-07 22:14:01 +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-09-08 10:50:30 +08:00
<para > A default installation does not setup a password for the administrator.
2003-09-07 22:14:01 +08:00
So here we will login and set one. We strongly suggest changing
2002-08-16 09:24:08 +08:00
'new-password' to your own.</para>
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>
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>
2003-09-07 22:14:01 +08:00
<screen > <userinput > <command > kill `pidof -x mysqld_safe mysqld`</command> </userinput> </screen>
2002-08-16 09:24:08 +08:00
<sect4 >
2003-09-29 06:10:55 +08:00
<title > <application > My<acronym > SQL</acronym> </application> init.d script</title>
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
case "$1" in
start)
echo "Starting MySQL daemon..."
2003-09-07 22:14:01 +08:00
/usr/bin/mysqld_safe --user=mysql 2> & 1 > /dev/null &
2002-08-16 09:24:08 +08:00
evaluate_retval
;;
stop)
echo "Stopping MySQL daemon..."
killproc mysqld
;;
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
</sect4>
</sect3>
</sect2>