[c30b739] | 1 | <sect2>
|
---|
[f0334b2] | 2 | <title>Configuring <application>My<acronym>SQL</acronym></application></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
|
---|
[a4be499] | 21 | unprivileged user and group.</para>
|
---|
[c30b739] | 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 |
|
---|
[5d9d6d9] | 31 | <para>A default installation does not setup a password for the administrator
|
---|
| 32 | so here we will set one. Replace <replaceable>[new-password]</replaceable>
|
---|
| 33 | with your own.</para>
|
---|
[c30b739] | 34 |
|
---|
[5d9d6d9] | 35 | <!--
|
---|
[993cff3] | 36 | <screen><userinput><command>mysql -uroot mysql</command></userinput>
|
---|
[c30b739] | 37 | Welcome to the MySQL monitor. Commands end with ; or \g.
|
---|
| 38 | Your MySQL connection id is 2 to server version: 3.23.51-log
|
---|
| 39 |
|
---|
| 40 | Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
|
---|
| 41 |
|
---|
[993cff3] | 42 | <prompt>mysql></prompt> <userinput><command>UPDATE user SET password=password('<replaceable>new-password</replaceable>') WHERE user='root';</command></userinput>
|
---|
[c30b739] | 43 | Query OK, 2 rows affected (0.00 sec)
|
---|
| 44 | Rows matched: 2 Changed: 2 Warnings: 0
|
---|
| 45 |
|
---|
[993cff3] | 46 | <prompt>mysql></prompt> <userinput><command>FLUSH PRIVILEGES;</command></userinput>
|
---|
[c30b739] | 47 | Query OK, 0 rows affected (0.00 sec)
|
---|
| 48 |
|
---|
[993cff3] | 49 | <prompt>mysql></prompt> <userinput><command>EXIT;</command></userinput>
|
---|
[c30b739] | 50 | bye
|
---|
[993cff3] | 51 | </screen>
|
---|
[5d9d6d9] | 52 | -->
|
---|
| 53 |
|
---|
[bc5af77] | 54 | <screen><userinput><command>mysqladmin -u root password <replaceable>[new-password]</replaceable></command></userinput></screen>
|
---|
[c30b739] | 55 |
|
---|
| 56 | <para>Now that we are done with the configuration of the server, we can
|
---|
| 57 | shut it down.</para>
|
---|
| 58 |
|
---|
[c213dfe] | 59 | <screen><userinput><command>mysqladmin -p shutdown</command></userinput></screen>
|
---|
[c30b739] | 60 |
|
---|
[f0334b2] | 61 | <para>To automate the running of <application>My<acronym>SQL</acronym></application>, use the following command to create
|
---|
[c30b739] | 62 | the init.d script:</para>
|
---|
| 63 |
|
---|
[317034a] | 64 | <screen><userinput><command>cat > /etc/rc.d/init.d/mysql << "EOF"</command>
|
---|
[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 |
|
---|
[c213dfe] | 74 | pid_file=/var/lib/mysql/`/bin/hostname`.pid
|
---|
| 75 |
|
---|
[c30b739] | 76 | case "$1" in
|
---|
| 77 | start)
|
---|
| 78 | echo "Starting MySQL daemon..."
|
---|
[6407476] | 79 | failure=0
|
---|
| 80 | if test -f "$pid_file"
|
---|
| 81 | then
|
---|
| 82 | if /bin/ps p `cat $pid_file` | grep mysqld >/dev/null
|
---|
| 83 | then
|
---|
| 84 | print_status warning running
|
---|
| 85 | exit 1
|
---|
| 86 | else
|
---|
| 87 | rm -f $pid_file
|
---|
| 88 | if test -f $pid_file
|
---|
| 89 | then
|
---|
| 90 | failure=1
|
---|
| 91 | fi
|
---|
| 92 | fi
|
---|
| 93 | fi
|
---|
| 94 | if [ $failure = 1 ]
|
---|
| 95 | then
|
---|
| 96 | (exit $failure)
|
---|
| 97 | evaluate_retval
|
---|
[c213dfe] | 98 | else
|
---|
[cf6e240f] | 99 | /usr/bin/mysqld_safe --user=mysql 2>&1 >/dev/null &
|
---|
[c213dfe] | 100 | evaluate_retval
|
---|
| 101 | fi
|
---|
[c30b739] | 102 | ;;
|
---|
| 103 |
|
---|
| 104 | stop)
|
---|
| 105 | echo "Stopping MySQL daemon..."
|
---|
[c213dfe] | 106 | if test -s "$pid_file"
|
---|
| 107 | then
|
---|
| 108 | kill `cat $pid_file`
|
---|
| 109 | sleep 1
|
---|
| 110 | failure=0
|
---|
| 111 | while [ -s $pid_file -a "$flags" != aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ]
|
---|
| 112 | do
|
---|
| 113 | [ -z "$flags" ]
|
---|
| 114 | flags=a$flags
|
---|
| 115 | sleep 1
|
---|
| 116 | done
|
---|
| 117 | if [ -s $pid_file ]
|
---|
| 118 | then failure=1
|
---|
| 119 | fi
|
---|
| 120 | (exit $failure)
|
---|
| 121 | evaluate_retval
|
---|
| 122 | else
|
---|
| 123 | print_status warning not_running
|
---|
| 124 | fi
|
---|
[c30b739] | 125 | ;;
|
---|
| 126 |
|
---|
| 127 | restart)
|
---|
| 128 | $0 stop
|
---|
| 129 | sleep 1
|
---|
| 130 | $0 start
|
---|
| 131 | ;;
|
---|
| 132 |
|
---|
| 133 | status)
|
---|
| 134 | statusproc /usr/sbin/mysqld
|
---|
| 135 | ;;
|
---|
| 136 |
|
---|
| 137 | *)
|
---|
| 138 | echo "Usage: $0 {start|stop|restart|status}"
|
---|
| 139 | exit 1
|
---|
| 140 | ;;
|
---|
| 141 | esac
|
---|
| 142 |
|
---|
| 143 | # End $rc_base/init.d/
|
---|
[317034a] | 144 | <command>EOF
|
---|
[9dcba70] | 145 | chmod 755 /etc/rc.d/init.d/mysql</command></userinput></screen>
|
---|
[c30b739] | 146 |
|
---|
[ca2217b] | 147 | <para>Create the symbolic links to this file in the relevant
|
---|
[9dcba70] | 148 | <filename class="directory">rc.d</filename> directory
|
---|
[c30b739] | 149 | with the following commands:</para>
|
---|
| 150 |
|
---|
[9dcba70] | 151 | <screen><userinput><command>cd /etc/rc.d/init.d &&
|
---|
[c30b739] | 152 | ln -sf ../init.d/mysql ../rc0.d/K26mysql &&
|
---|
| 153 | ln -sf ../init.d/mysql ../rc1.d/K26mysql &&
|
---|
| 154 | ln -sf ../init.d/mysql ../rc2.d/K26mysql &&
|
---|
| 155 | ln -sf ../init.d/mysql ../rc3.d/S34mysql &&
|
---|
| 156 | ln -sf ../init.d/mysql ../rc4.d/S34mysql &&
|
---|
| 157 | ln -sf ../init.d/mysql ../rc5.d/S34mysql &&
|
---|
[9dcba70] | 158 | ln -sf ../init.d/mysql ../rc6.d/K26mysql</command></userinput></screen>
|
---|
[c30b739] | 159 |
|
---|
[5d9d6d9] | 160 | <para>Finally, add this entry to your <filename>ld.so.conf</filename>
|
---|
| 161 | file so that programs which utilize
|
---|
| 162 | <application>My<acronym>SQL</acronym></application> can find its
|
---|
| 163 | libraries:</para>
|
---|
| 164 |
|
---|
| 165 | <screen><userinput><command>echo /usr/lib/mysql >> /etc/ld.so.conf</command></userinput></screen>
|
---|
[c30b739] | 166 |
|
---|
| 167 | </sect3>
|
---|
| 168 |
|
---|
| 169 | </sect2>
|
---|