[c30b739] | 1 | <sect2>
|
---|
[9dcba70] | 2 | <title>Configuring MySQL</title>
|
---|
[c30b739] | 3 |
|
---|
| 4 | <sect3>
|
---|
| 5 | <title>Config files</title>
|
---|
| 6 |
|
---|
[e80cc95] | 7 | <para><filename>/etc/my.cnf</filename>, <filename>~/.my.cnf</filename></para>
|
---|
[c30b739] | 8 |
|
---|
| 9 | </sect3>
|
---|
| 10 |
|
---|
| 11 | <sect3>
|
---|
| 12 | <title>Configuration Information</title>
|
---|
| 13 |
|
---|
| 14 | <para>There are several default configurations file available in
|
---|
[9dcba70] | 15 | <filename class="directory">/usr/share/mysql</filename> which you can use.</para>
|
---|
[c30b739] | 16 |
|
---|
[9dcba70] | 17 | <screen><userinput><command>cp /usr/share/mysql/my-medium.cnf /etc/my.cnf</command>
|
---|
| 18 | </userinput></screen>
|
---|
[c30b739] | 19 |
|
---|
| 20 | <para>We can now install a database and change the ownership to the
|
---|
| 21 | unpriviledged user and group.</para>
|
---|
| 22 |
|
---|
[9dcba70] | 23 | <screen><userinput><command>mysql_install_db
|
---|
| 24 | chown -R mysql:mysql /var/lib/mysql</command></userinput></screen>
|
---|
[c30b739] | 25 |
|
---|
| 26 | <para>Further configuration requires that the mysql server be running:</para>
|
---|
| 27 |
|
---|
[9dcba70] | 28 | <screen><userinput><command>mysqld_safe --user=mysql 2>&1 >/dev/null &</command>
|
---|
| 29 | </userinput></screen>
|
---|
[c30b739] | 30 |
|
---|
| 31 | <para>A default installation, does not setup a password for the administrator.
|
---|
[9dcba70] | 32 | So here we will login and set one. We strongly suggest changing
|
---|
[c30b739] | 33 | 'new-password' to your own.</para>
|
---|
| 34 |
|
---|
[9dcba70] | 35 | <screen><userinput><command>mysql -uroot mysql
|
---|
[c30b739] | 36 | Welcome to the MySQL monitor. Commands end with ; or \g.
|
---|
| 37 | Your MySQL connection id is 2 to server version: 3.23.51-log
|
---|
| 38 |
|
---|
| 39 | Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
|
---|
| 40 |
|
---|
[9dcba70] | 41 | mysql> UPDATE user SET password=password('new-password') WHERE user='root';
|
---|
[c30b739] | 42 | Query OK, 2 rows affected (0.00 sec)
|
---|
| 43 | Rows matched: 2 Changed: 2 Warnings: 0
|
---|
| 44 |
|
---|
[9dcba70] | 45 | mysql> FLUSH PRIVILEGES;
|
---|
[c30b739] | 46 | Query OK, 0 rows affected (0.00 sec)
|
---|
| 47 |
|
---|
[9dcba70] | 48 | mysql> EXIT;
|
---|
[c30b739] | 49 | bye
|
---|
[9dcba70] | 50 | </command></userinput></screen>
|
---|
[c30b739] | 51 |
|
---|
| 52 | <para>Now that we are done with the configuration of the server, we can
|
---|
| 53 | shut it down.</para>
|
---|
| 54 |
|
---|
[9dcba70] | 55 | <screen><userinput><command>kill `pidof -x mysqld_safe mysqld`</command></userinput></screen>
|
---|
[c30b739] | 56 |
|
---|
| 57 |
|
---|
| 58 | <sect4>
|
---|
[9dcba70] | 59 | <title>MySQL init.d script</title>
|
---|
[c30b739] | 60 |
|
---|
[9dcba70] | 61 | <para>To automate the running of MySQL, use the following command to create
|
---|
[c30b739] | 62 | the init.d script:</para>
|
---|
| 63 |
|
---|
[9dcba70] | 64 | <screen><userinput><command>cat > /etc/rc.d/init.d/mysql << "EOF"
|
---|
[c30b739] | 65 | #!/bin/bash
|
---|
| 66 | # Begin $rc_base/init.d/
|
---|
| 67 |
|
---|
| 68 | # Based on sysklogd script from LFS-3.1 and earlier.
|
---|
| 69 | # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
|
---|
| 70 |
|
---|
| 71 | source /etc/sysconfig/rc
|
---|
| 72 | source $rc_functions
|
---|
| 73 |
|
---|
| 74 | case "$1" in
|
---|
| 75 | start)
|
---|
| 76 | echo "Starting MySQL daemon..."
|
---|
[9dcba70] | 77 | /usr/bin/mysqld_safe --user=mysql 2>&1 >/dev/null &
|
---|
[c30b739] | 78 | evaluate_retval
|
---|
| 79 | ;;
|
---|
| 80 |
|
---|
| 81 | stop)
|
---|
| 82 | echo "Stopping MySQL daemon..."
|
---|
| 83 | killproc mysqld
|
---|
| 84 | ;;
|
---|
| 85 |
|
---|
| 86 | restart)
|
---|
| 87 | $0 stop
|
---|
| 88 | sleep 1
|
---|
| 89 | $0 start
|
---|
| 90 | ;;
|
---|
| 91 |
|
---|
| 92 | status)
|
---|
| 93 | statusproc /usr/sbin/mysqld
|
---|
| 94 | ;;
|
---|
| 95 |
|
---|
| 96 | *)
|
---|
| 97 | echo "Usage: $0 {start|stop|restart|status}"
|
---|
| 98 | exit 1
|
---|
| 99 | ;;
|
---|
| 100 | esac
|
---|
| 101 |
|
---|
| 102 | # End $rc_base/init.d/
|
---|
[9dcba70] | 103 | EOF
|
---|
| 104 | chmod 755 /etc/rc.d/init.d/mysql</command></userinput></screen>
|
---|
[c30b739] | 105 |
|
---|
[ca2217b] | 106 | <para>Create the symbolic links to this file in the relevant
|
---|
[9dcba70] | 107 | <filename class="directory">rc.d</filename> directory
|
---|
[c30b739] | 108 | with the following commands:</para>
|
---|
| 109 |
|
---|
[9dcba70] | 110 | <screen><userinput><command>cd /etc/rc.d/init.d &&
|
---|
[c30b739] | 111 | ln -sf ../init.d/mysql ../rc0.d/K26mysql &&
|
---|
| 112 | ln -sf ../init.d/mysql ../rc1.d/K26mysql &&
|
---|
| 113 | ln -sf ../init.d/mysql ../rc2.d/K26mysql &&
|
---|
| 114 | ln -sf ../init.d/mysql ../rc3.d/S34mysql &&
|
---|
| 115 | ln -sf ../init.d/mysql ../rc4.d/S34mysql &&
|
---|
| 116 | ln -sf ../init.d/mysql ../rc5.d/S34mysql &&
|
---|
[9dcba70] | 117 | ln -sf ../init.d/mysql ../rc6.d/K26mysql</command></userinput></screen>
|
---|
[c30b739] | 118 |
|
---|
| 119 | </sect4>
|
---|
| 120 |
|
---|
| 121 | </sect3>
|
---|
| 122 |
|
---|
| 123 | </sect2>
|
---|