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