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