4 \chapter{Installing and Configuring MySQL}
6 \index[general]{MySQL!Installing and Configuring }
7 \index[general]{Installing and Configuring MySQL }
9 \section{Installing and Configuring MySQL -- Phase I}
10 \index[general]{Installing and Configuring MySQL -- Phase I }
11 \index[general]{Phase I!Installing and Configuring MySQL -- }
13 If you use the ./configure \lstinline:--:with-mysql=mysql-directory statement for
14 configuring {\bf Bacula}, you will need MySQL version 4.1 or later installed
15 in the {\bf mysql-directory}. If you are using one of the new modes such as
16 ANSI/ISO compatibility, you may experience problems.
18 If MySQL is installed in the standard system location, you need only enter
19 {\bf \lstinline:--:with-mysql} since the configure program will search all the
20 standard locations. If you install MySQL in your home directory or some
21 other 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 The notes below describe how to build MySQL from the source tar files. If
30 you have a pre-installed MySQL, you can return to complete the installation
31 of Bacula, then come back to Phase II of the MySQL installation. If you
32 wish to install MySQL from rpms, you will probably need to install
38 mysql-server-<version>.rpm
39 mysql-devel-<version>.rpm
43 If you wish to install them from debs, you will probably need the
48 mysql-server-<version>.deb
49 mysql-client-<version>.deb
50 libmysqlclient15-dev-<version>.deb
51 libmysqlclient15off-<version>.deb
55 The names of the packages may vary from distribution to
56 distribution. It is important to have the {\bf devel} or {\bf dev} package loaded as
57 it contains the libraries and header files necessary to build
58 Bacula. There may be additional packages that are required to
59 install the above, for example, zlib and openssl.
61 Once these packages are installed, you will be able to build Bacula (using
62 the files installed with the mysql package, then run MySQL using the
63 files installed with mysql-server. If you have installed MySQL by debs or rpms,
64 please skip Phase I below, and return to complete the installation of
65 Bacula, then come back to Phase II of the MySQL installation when indicated
68 Beginning with Bacula version 1.31, the thread safe version of the
69 MySQL client library is used, and hence you should add the {\bf
70 \lstinline:--:enable-thread-safe-client} option to the {\bf
71 ./configure} as shown below:
74 \item Download MySQL source code from
75 \elink{www.mysql.com/downloads}{http://www.mysql.com/downloads}
77 \item Detar it with something like:
79 {\bf tar xvfz mysql-filename}
81 Note, the above command requires GNU tar. If you do not have GNU tar, a
84 {\bf zcat mysql-filename \lstinline+|+ tar xvf - }
86 will probably accomplish the same thing.
88 \item cd {\bf mysql-source-directory}
90 where you replace {\bf mysql-source-directory} with the directory name where
91 you put the MySQL source code.
93 \item ./configure \lstinline:--:enable-thread-safe-client \lstinline:--:prefix=mysql-directory
95 where you replace {\bf mysql-directory} with the directory name where you
96 want to install mysql. Normally for system wide use this is /usr/local/mysql.
97 In my case, I use \~{}kern/mysql.
101 This takes a bit of time.
105 This will put all the necessary binaries, libraries and support files into
106 the {\bf mysql-directory} that you specified above.
108 \item ./scripts/mysql\_install\_db
110 This will create the necessary MySQL databases for controlling user access.
111 Note, this script can also be found in the {\bf bin} directory in the
112 installation directory
116 The MySQL client library {\bf mysqlclient} requires the gzip compression
117 library {\bf libz.a} or {\bf libz.so}. If you are using rpm packages, these
118 libraries are in the {\bf libz-devel} package. On Debian systems, you will
119 need to load the {\bf zlib1g-dev} package. If you are not using rpms or debs,
120 you will need to find the appropriate package for your system.
122 At this point, you should return to completing the installation of {\bf
123 Bacula}. Later after Bacula is installed, come back to this chapter to
124 complete the installation. Please note, the installation files used in the
125 second phase of the MySQL installation are created during the Bacula
129 \section{Installing and Configuring MySQL -- Phase II}
130 \index[general]{Installing and Configuring MySQL -- Phase II }
131 \index[general]{Phase II!Installing and Configuring MySQL -- }
133 At this point, you should have built and installed MySQL, or already have a
134 running MySQL, and you should have configured, built and installed {\bf
135 Bacula}. If not, please complete these items before proceeding.
137 Please note that the {\bf ./configure} used to build {\bf Bacula} will need to
138 include {\bf \lstinline:--:with-mysql=mysql-directory}, where {\bf mysql-directory} is the
139 directory name that you specified on the ./configure command for configuring
140 MySQL. This is needed so that Bacula can find the necessary include headers
141 and library files for interfacing to MySQL.
143 {\bf Bacula} will install scripts for manipulating the database (create,
144 delete, make tables etc) into the main installation directory. These files
145 will be of the form *\_bacula\_* (e.g. create\_bacula\_database). These files
146 are also available in the \lt{}bacula-src\gt{}/src/cats directory after
147 running ./configure. If you inspect create\_bacula\_database, you will see
148 that it calls create\_mysql\_database. The *\_bacula\_* files are provided for
149 convenience. It doesn't matter what database you have chosen;
150 create\_bacula\_database will always create your database.
152 Now you will create the Bacula MySQL database and the tables that Bacula uses.
156 \item Start {\bf mysql}. You might want to use the {\bf startmysql} script
157 provided in the Bacula release.
159 \item cd \lt{}install-directory\gt{}
160 This directory contains the Bacula catalog interface routines.
162 \item ./grant\_mysql\_privileges
163 This script creates unrestricted access rights for the user {\bf bacula}.
164 You may want to modify it to suit your situation. Please
165 note that none of the userids, including root, are password protected.
166 If you need more security, please assign a password to the root user
167 and to bacula. The program {\bf mysqladmin} can be used for this.
169 \item ./create\_mysql\_database
170 This script creates the MySQL {\bf bacula} database. The databases you
171 create as well as the access databases will be located in
172 \lt{}install-dir\gt{}/var/ in a subdirectory with the name of the
173 database, where \lt{}install-dir\gt{} is the directory name that you
174 specified on the {\bf \lstinline:--:prefix} option. This can be important to
175 know if you want to make a special backup of the Bacula database or to
178 \item ./make\_mysql\_tables
179 This script creates the MySQL tables used by {\bf Bacula}.
182 Each of the three scripts (grant\_mysql\_privileges, create\_mysql\_database
183 and make\_mysql\_tables) allows the addition of a command line argument. This
184 can be useful for specifying the user and or password. For example, you might
185 need to add {\bf -u root} to the command line to have sufficient privilege to
186 create the Bacula tables.
188 To take a closer look at the access privileges that you have setup with the
193 mysql-directory/bin/mysql -u root mysql
198 \section{Re-initializing the Catalog Database}
199 \index[general]{Database!Re-initializing the Catalog }
200 \index[general]{Re-initializing the Catalog Database }
202 After you have done some initial testing with {\bf Bacula}, you will probably
203 want to re-initialize the catalog database and throw away all the test Jobs
204 that you ran. To do so, you can do the following:
208 cd <install-directory>
214 Please note that all information in the database will be lost and you will be
215 starting from scratch. If you have written on any Volumes, you must write an
216 end of file mark on the volume so that Bacula can reuse it. Do so with:
220 (stop Bacula or unmount the drive)
221 mt -f /dev/nst0 rewind
226 Where you should replace {\bf /dev/nst0} with the appropriate tape drive
227 device name for your machine.
229 \section{Linking Bacula with MySQL}
230 \index[general]{Linking Bacula with MySQL }
231 \index[general]{MySQL!Linking Bacula with }
232 \index[general]{Upgrading}
234 After configuring Bacula with
236 ./configure \lstinline:--:enable-thread-safe-client \lstinline:--:prefix=\lt{}mysql-directory\gt{}
237 where \lt{}mysql-directory\gt{} is in my case {\bf /home/kern/mysql}, you may
238 have to configure the loader so that it can find the MySQL shared libraries.
239 If you have previously followed this procedure and later add the {\bf
240 \lstinline:--:enable-thread-safe-client} options, you will need to rerun the {\bf
241 ldconfig} program shown below. If you put MySQL in a standard place such as
242 {\bf /usr/lib} or {\bf /usr/local/lib} this will not be necessary, but in my
243 case it is. The description that follows is Linux specific. For other
244 operating systems, please consult your manuals on how to do the same thing:
246 First edit: {\bf /etc/ld.so.conf} and add a new line to the end of the file
247 with the name of the mysql-directory. In my case, it is:
249 /home/kern/mysql/lib/mysql then rebuild the loader's cache with:
251 /sbin/ldconfig If you upgrade to a new version of {\bf MySQL}, the shared
252 library names will probably change, and you must re-run the {\bf
253 /sbin/ldconfig} command so that the runtime loader can find them.
255 Alternatively, your system my have a loader environment variable that can be
256 set. For example, on a Solaris system where I do not have root permission, I
259 LD\_LIBRARY\_PATH=/home/kern/mysql/lib/mysql
261 Finally, if you have encryption enabled in MySQL, you may need to add {\bf
262 -lssl -lcrypto} to the link. In that case, you can either export the
263 appropriate LDFLAGS definition, or alternatively, you can include them
264 directly on the ./configure line as in:
268 LDFLAGS="-lssl -lcyrpto" \
274 \section{Installing MySQL from RPMs}
275 \index[general]{MySQL!Installing from RPMs}
276 \index[general]{Installing MySQL from RPMs}
277 If you are installing MySQL from RPMs, you will need to install
278 both the MySQL binaries and the client libraries. The client
279 libraries are usually found in a devel package, so you must
289 This will be the same with most other package managers too.
291 \section{Upgrading MySQL}
292 \index[general]{Upgrading MySQL }
293 \index[general]{Upgrading!MySQL }
294 \index[general]{Upgrading}
295 If you upgrade MySQL, you must reconfigure, rebuild, and re-install
296 Bacula otherwise you are likely to get bizarre failures. If you
297 install from rpms and you upgrade MySQL, you must also rebuild Bacula.
298 You can do so by rebuilding from the source rpm. To do so, you may need
299 to modify the bacula.spec file to account for the new MySQL version.