4 \section*{Installing and Configuring MySQL}
6 \index[general]{MySQL!Installing and Configuring }
7 \index[general]{Installing and Configuring MySQL }
8 \addcontentsline{toc}{section}{Installing and Configuring MySQL}
10 \subsection*{Installing and Configuring MySQL -- Phase I}
11 \index[general]{Installing and Configuring MySQL -- Phase I }
12 \index[general]{Phase I!Installing and Configuring MySQL -- }
13 \addcontentsline{toc}{subsection}{Installing and Configuring MySQL -- Phase I}
15 If you use the ./configure \verb{--{with-mysql=mysql-directory statement for
16 configuring {\bf Bacula}, you will need MySQL version 3.23.33 or later
17 installed in the {\bf mysql-directory} (we are currently using 3.23.56). If
18 MySQL is installed in the standard system location, you need only enter {\bf
19 \verb{--{with-mysql} since the configure program will search all the standard
20 locations. If you install MySQL in your home directory or some other
21 non-standard directory, you will need to provide the full path to it.
23 Installing and Configuring MySQL is not difficult but can be confusing the
24 first time. As a consequence, below, we list the steps that we used to install
25 it on our machines. Please note that our configuration leaves MySQL without
26 any user passwords. This may be an undesirable situation if you have other
29 Please note that as of Bacula version 1.31, the thread safe version of the
30 MySQL client library is used, and hence you must add the {\bf
31 \verb{--{enable-thread-safe-client} option to the {\bf ./configure} as shown below:
34 \item Download MySQL source code from
35 \elink{www.mysql.com/downloads}{http://www.mysql.com/downloads}
37 \item Detar it with something like:
39 {\bf tar xvfz mysql-filename}
41 Note, the above command requires GNU tar. If you do not have GNU tar, a
44 {\bf zcat mysql-filename | tar xvf -
46 } will probably accomplish the same thing.
48 \item cd {\bf mysql-source-directory}
50 where you replace {\bf mysql-source-directory} with the directory name where
51 you put the MySQL source code.
53 \item ./configure \verb{--{enable-thread-safe-client \verb{--{prefix=mysql-directory
55 where you replace {\bf mysql-directory} with the directory name where you
56 want to install mysql. Normally for system wide use this is /usr/local/mysql.
57 In my case, I use \~{}kern/mysql.
61 This takes a bit of time.
65 This will put all the necessary binaries, libraries and support files into
66 the {\bf mysql-directory} that you specified above.
68 \item ./scripts/mysql\_install\_db
70 This will create the necessary MySQL databases for controlling user access.
71 Note, this script can also be found in the {\bf bin} directory in the
72 installation directory
76 The MySQL client library {\bf mysqlclient} requires the gzip compression
77 library {\bf libz.a} or {\bf libz.so}. If you are using rpm packages, these
78 libraries are in the {\bf libz-devel} package. On Debian systems, you will
79 need to load the {\bf zlib1g-dev} package. If you are not using rpms or debs,
80 you will need to find the appropriate package for your system.
82 At this point, you should return to completing the installation of {\bf
83 Bacula}. Later after Bacula is installed, come back to this chapter to
84 complete the installation. Please note, the installation files used in the
85 second phase of the MySQL installation are created during the Bacula
89 \subsection*{Installing and Configuring MySQL -- Phase II}
90 \index[general]{Installing and Configuring MySQL -- Phase II }
91 \index[general]{Phase II!Installing and Configuring MySQL -- }
92 \addcontentsline{toc}{subsection}{Installing and Configuring MySQL -- Phase
95 At this point, you should have built and installed MySQL, or already have a
96 running MySQL, and you should have configured, built and installed {\bf
97 Bacula}. If not, please complete these items before proceeding.
99 Please note that the {\bf ./configure} used to build {\bf Bacula} will need to
100 include {\bf \verb{--{with-mysql=mysql-directory}, where {\bf mysql-directory} is the
101 directory name that you specified on the ./configure command for configuring
102 MySQL. This is needed so that Bacula can find the necessary include headers
103 and library files for interfacing to MySQL.
105 {\bf Bacula} will install scripts for manipulating the database (create,
106 delete, make tables etc) into the main installation directory. These files
107 will be of the form *\_bacula\_* (e.g. create\_bacula\_database). These files
108 are also available in the \lt{}bacula-src\gt{}/src/cats directory after
109 running ./configure. If you inspect create\_bacula\_database, you will see
110 that it calls create\_mysql\_database. The *\_bacula\_* files are provided for
111 convenience. It doesn't matter what database you have chosen;
112 create\_bacula\_database will always create your database.
114 Now you will create the Bacula MySQL database and the tables that Bacula uses.
118 \item Start {\bf mysql}. You might want to use the {\bf startmysql} script
119 provided in the Bacula release.
120 \item cd \lt{}install-directory\gt{}
122 This directory contains the Bacula catalog interface routines.
124 \item ./grant\_mysql\_privileges
126 This script creates unrestricted access rights for {\bf kern}, {\bf kelvin},
127 and {\bf bacula}. You may want to modify it to suit your situation. Please
128 note that none of these userids, including root, are password protected.
130 \item ./create\_mysql\_database
132 This script creates the MySQL {\bf bacula} database. The databases you create
133 as well as the access databases will be located in \lt{}install-dir\gt{}/var/
134 in a subdirectory with the name of the database, where \lt{}install-dir\gt{}
135 is the directory name that you specified on the {\bf \verb{--{prefix} option. This
136 can be important to know if you want to make a special backup of the Bacula
137 database or to check its size.
139 \item ./make\_mysql\_tables
141 This script creates the MySQL tables used by {\bf Bacula}.
144 Each of the three scripts (grant\_mysql\_privileges, create\_mysql\_database
145 and make\_mysql\_tables) allows the addition of a command line argument. This
146 can be useful for specifying the user and or password. For example, you might
147 need to add {\bf -u root} to the command line to have sufficient privilege to
148 create the Bacula tables.
150 To take a closer look at the access privileges that you have setup with the
155 mysql-directory/bin/mysql -u root mysql
160 \subsection*{Re-initializing the Catalog Database}
161 \index[general]{Database!Re-initializing the Catalog }
162 \index[general]{Re-initializing the Catalog Database }
163 \addcontentsline{toc}{subsection}{Re-initializing the Catalog Database}
165 After you have done some initial testing with {\bf Bacula}, you will probably
166 want to re-initialize the catalog database and throw away all the test Jobs
167 that you ran. To do so, you can do the following:
171 cd <install-directory>
177 Please note that all information in the database will be lost and you will be
178 starting from scratch. If you have written on any Volumes, you must write an
179 end of file mark on the volume so that Bacula can reuse it. Do so with:
183 (stop Bacula or unmount the drive)
184 mt -f /dev/nst0 rewind
189 Where you should replace {\bf /dev/nst0} with the appropriate tape drive
190 device name for your machine.
192 \subsection*{Linking Bacula with MySQL}
193 \index[general]{Linking Bacula with MySQL }
194 \index[general]{MySQL!Linking Bacula with }
195 \addcontentsline{toc}{subsection}{Linking Bacula with MySQL}
197 After configuring Bacula with
199 ./configure \verb{--{enable-thread-safe-client \verb{--{prefix=\lt{}mysql-directory\gt{}
200 where \lt{}mysql-directory\gt{} is in my case {\bf /home/kern/mysql}, you may
201 have to configure the loader so that it can find the MySQL shared libraries.
202 If you have previously followed this procedure and later add the {\bf
203 \verb{--{enable-thread-safe-client} options, you will need to rerun the {\bf
204 ldconfig} program shown below. If you put MySQL in a standard place such as
205 {\bf /usr/lib} or {\bf /usr/local/lib} this will not be necessary, but in my
206 case it is. The description that follows is Linux specific. For other
207 operating systems, please consult your manuals on how to do the same thing:
209 First edit: {\bf /etc/ld.so.conf} and add a new line to the end of the file
210 with the name of the mysql-directory. In my case, it is:
212 /home/kern/mysql/lib/mysql then rebuild the loader's cache with:
214 /sbin/ldconfig If you upgrade to a new version of {\bf MySQL}, the shared
215 library names will probably change, and you must re-run the {\bf
216 /sbin/ldconfig} command so that the runtime loader can find them.
218 Alternatively, your system my have a loader environment variable that can be
219 set. For example, on a Solaris system where I do not have root permission, I
222 LD\_LIBRARY\_PATH=/home/kern/mysql/lib/mysql
224 Finally, if you have encryption enabled in MySQL, you may need to add {\bf
225 -lssl -lcrypto} to the link. In that case, you can either export the
226 appropriate LDFLAGS definition, or alternatively, you can include them
227 directly on the ./configure line as in:
231 LDFLAGS="-lssl -lcyrpto" \