mirror of
https://github.com/Zeckmathederg/glfs.git
synced 2025-02-09 03:37:18 +08:00
git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@1292 af4574ff-66df-0310-9fd7-8a98e5e911e0
124 lines
3.8 KiB
XML
124 lines
3.8 KiB
XML
<sect2>
|
|
<title>Configuring <application>My<acronym>SQL</acronym></application></title>
|
|
|
|
<sect3>
|
|
<title>Config files</title>
|
|
|
|
<para><filename>/etc/my.cnf</filename>, <filename>~/.my.cnf</filename></para>
|
|
|
|
</sect3>
|
|
|
|
<sect3>
|
|
<title>Configuration Information</title>
|
|
|
|
<para>There are several default configurations file available in
|
|
<filename class="directory">/usr/share/mysql</filename> which you can use.</para>
|
|
|
|
<screen><userinput><command>cp /usr/share/mysql/my-medium.cnf /etc/my.cnf</command>
|
|
</userinput></screen>
|
|
|
|
<para>We can now install a database and change the ownership to the
|
|
unprivileged user and group.</para>
|
|
|
|
<screen><userinput><command>mysql_install_db
|
|
chown -R mysql:mysql /var/lib/mysql</command></userinput></screen>
|
|
|
|
<para>Further configuration requires that the mysql server be running:</para>
|
|
|
|
<screen><userinput><command>mysqld_safe --user=mysql 2>&1 >/dev/null &</command>
|
|
</userinput></screen>
|
|
|
|
<para>A default installation does not setup a password for the administrator.
|
|
So here we will login and set one. We strongly suggest changing
|
|
'new-password' to your own.</para>
|
|
|
|
<screen><userinput><command>mysql -uroot mysql</command></userinput>
|
|
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.
|
|
|
|
<prompt>mysql></prompt> <userinput><command>UPDATE user SET password=password('<replaceable>new-password</replaceable>') WHERE user='root';</command></userinput>
|
|
Query OK, 2 rows affected (0.00 sec)
|
|
Rows matched: 2 Changed: 2 Warnings: 0
|
|
|
|
<prompt>mysql></prompt> <userinput><command>FLUSH PRIVILEGES;</command></userinput>
|
|
Query OK, 0 rows affected (0.00 sec)
|
|
|
|
<prompt>mysql></prompt> <userinput><command>EXIT;</command></userinput>
|
|
bye
|
|
</screen>
|
|
|
|
<para>Now that we are done with the configuration of the server, we can
|
|
shut it down.</para>
|
|
|
|
<screen><userinput><command>kill `pidof -x mysqld_safe mysqld`</command></userinput></screen>
|
|
|
|
|
|
<sect4>
|
|
<title><application>My<acronym>SQL</acronym></application> init.d script</title>
|
|
|
|
<para>To automate the running of <application>My<acronym>SQL</acronym></application>, use the following command to create
|
|
the init.d script:</para>
|
|
|
|
<screen><userinput><command>cat > /etc/rc.d/init.d/mysql << "EOF"</command>
|
|
#!/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..."
|
|
/usr/bin/mysqld_safe --user=mysql 2>&1 >/dev/null &
|
|
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/
|
|
<command>EOF
|
|
chmod 755 /etc/rc.d/init.d/mysql</command></userinput></screen>
|
|
|
|
<para>Create the symbolic links to this file in the relevant
|
|
<filename class="directory">rc.d</filename> directory
|
|
with the following commands:</para>
|
|
|
|
<screen><userinput><command>cd /etc/rc.d/init.d &&
|
|
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 &&
|
|
ln -sf ../init.d/mysql ../rc6.d/K26mysql</command></userinput></screen>
|
|
|
|
</sect4>
|
|
|
|
</sect3>
|
|
|
|
</sect2>
|