<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!--Converted with LaTeX2HTML 2008 (1.71) original version by: Nikos Drakos, CBLU, University of Leeds * revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan * with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --> <HTML> <HEAD> <TITLE>Installing and Configuring MySQL</TITLE> <META NAME="description" CONTENT="Installing and Configuring MySQL"> <META NAME="keywords" CONTENT="main"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <META NAME="Generator" CONTENT="LaTeX2HTML v2008"> <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"> <LINK REL="STYLESHEET" HREF="main.css"> <LINK REL="next" HREF="Installing_Configuring_Post.html"> <LINK REL="previous" HREF="Using_Bacula_Improve_Comput.html"> <LINK REL="up" HREF="Bacula_Main_Reference.html"> <LINK REL="next" HREF="Installing_Configuring_Post.html"> </HEAD> <BODY > <!--Navigation Panel--> <A NAME="tex2html1946" HREF="Installing_Configuring_Post.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html1940" HREF="Bacula_Main_Reference.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html1934" HREF="Using_Bacula_Improve_Comput.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html1942" HREF="Contents.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html1944" HREF="Thanks.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html1947" HREF="Installing_Configuring_Post.html">Installing and Configuring PostgreSQL</A> <B> Up:</B> <A NAME="tex2html1941" HREF="Bacula_Main_Reference.html">Bacula Main Reference</A> <B> Previous:</B> <A NAME="tex2html1935" HREF="Using_Bacula_Improve_Comput.html">Using Bacula to Improve</A> <B> <A NAME="tex2html1943" HREF="Contents.html">Contents</A></B> <B> <A NAME="tex2html1945" HREF="Thanks.html">Index</A></B> <BR> <BR> <!--End of Navigation Panel--> <!--Table of Child-Links--> <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A> <UL> <LI><A NAME="tex2html1948" HREF="Installing_Configuring_MySQ.html#SECTION004210000000000000000">Installing and Configuring MySQL - Phase I</A> <LI><A NAME="tex2html1949" HREF="Installing_Configuring_MySQ.html#SECTION004220000000000000000">Installing and Configuring MySQL - Phase II</A> <LI><A NAME="tex2html1950" HREF="Installing_Configuring_MySQ.html#SECTION004230000000000000000">Re-initializing the Catalog Database</A> <LI><A NAME="tex2html1951" HREF="Installing_Configuring_MySQ.html#SECTION004240000000000000000">Linking Bacula with MySQL</A> <LI><A NAME="tex2html1952" HREF="Installing_Configuring_MySQ.html#SECTION004250000000000000000">Installing MySQL from RPMs</A> <LI><A NAME="tex2html1953" HREF="Installing_Configuring_MySQ.html#SECTION004260000000000000000">Upgrading MySQL</A> </UL> <!--End of Table of Child-Links--> <HR> <H1><A NAME="SECTION004200000000000000000"></A> <A NAME="MySqlChapter"></A> <BR> Installing and Configuring MySQL </H1> <A NAME="20415"></A> <A NAME="20416"></A> <P> <H1><A NAME="SECTION004210000000000000000"> Installing and Configuring MySQL - Phase I</A> </H1> <A NAME="20418"></A> <A NAME="20419"></A> <P> If you use the ./configure <code>--</code>with-mysql=mysql-directory statement for configuring <B>Bacula</B>, you will need MySQL version 4.1 or later installed in the <B>mysql-directory</B>. If you are using one of the new modes such as ANSI/ISO compatibility, you may experience problems. <P> If MySQL is installed in the standard system location, you need only enter <B><code>--</code>with-mysql</B> since the configure program will search all the standard locations. If you install MySQL in your home directory or some other non-standard directory, you will need to provide the full path to it. <P> Installing and Configuring MySQL is not difficult but can be confusing the first time. As a consequence, below, we list the steps that we used to install it on our machines. Please note that our configuration leaves MySQL without any user passwords. This may be an undesirable situation if you have other users on your system. <P> The notes below describe how to build MySQL from the source tar files. If you have a pre-installed MySQL, you can return to complete the installation of Bacula, then come back to Phase II of the MySQL installation. If you wish to install MySQL from rpms, you will probably need to install the following: <P> <PRE> mysql-<version>.rpm mysql-server-<version>.rpm mysql-devel-<version>.rpm </PRE> <P> If you wish to install them from debs, you will probably need the following: <P> <PRE> mysql-server-<version>.deb mysql-client-<version>.deb libmysqlclient15-dev-<version>.deb libmysqlclient15off-<version>.deb </PRE> <P> The names of the packages may vary from distribution to distribution. It is important to have the <B>devel</B> or <B>dev</B> package loaded as it contains the libraries and header files necessary to build Bacula. There may be additional packages that are required to install the above, for example, zlib and openssl. <P> Once these packages are installed, you will be able to build Bacula (using the files installed with the mysql package, then run MySQL using the files installed with mysql-server. If you have installed MySQL by debs or rpms, please skip Phase I below, and return to complete the installation of Bacula, then come back to Phase II of the MySQL installation when indicated to do so. <P> Beginning with Bacula version 1.31, the thread safe version of the MySQL client library is used, and hence you should add the <B><code>--</code>enable-thread-safe-client</B> option to the <B>./configure</B> as shown below: <P> <OL> <LI>Download MySQL source code from www.mysql.com/downloadshttp://www.mysql.com/downloads <P> </LI> <LI>Detar it with something like: <P> <B>tar xvfz mysql-filename</B> <P> Note, the above command requires GNU tar. If you do not have GNU tar, a command such as: <P> <B>zcat mysql-filename <code>|</code> tar xvf - </B> <P> will probably accomplish the same thing. <P> </LI> <LI>cd <B>mysql-source-directory</B> <P> where you replace <B>mysql-source-directory</B> with the directory name where you put the MySQL source code. <P> </LI> <LI>./configure <code>--</code>enable-thread-safe-client <code>--</code>prefix=mysql-directory <P> where you replace <B>mysql-directory</B> with the directory name where you want to install mysql. Normally for system wide use this is /usr/local/mysql. In my case, I use ~kern/mysql. <P> </LI> <LI>make <P> This takes a bit of time. <P> </LI> <LI>make install <P> This will put all the necessary binaries, libraries and support files into the <B>mysql-directory</B> that you specified above. <P> </LI> <LI>./scripts/mysql_install_db <P> This will create the necessary MySQL databases for controlling user access. Note, this script can also be found in the <B>bin</B> directory in the installation directory <P> </LI> </OL> <P> The MySQL client library <B>mysqlclient</B> requires the gzip compression library <B>libz.a</B> or <B>libz.so</B>. If you are using rpm packages, these libraries are in the <B>libz-devel</B> package. On Debian systems, you will need to load the <B>zlib1g-dev</B> package. If you are not using rpms or debs, you will need to find the appropriate package for your system. <P> At this point, you should return to completing the installation of <B>Bacula</B>. Later after Bacula is installed, come back to this chapter to complete the installation. Please note, the installation files used in the second phase of the MySQL installation are created during the Bacula Installation. <P> <A NAME="mysql_phase2"></A> <H1><A NAME="SECTION004220000000000000000"> Installing and Configuring MySQL - Phase II</A> </H1> <A NAME="20451"></A> <A NAME="20452"></A> <P> At this point, you should have built and installed MySQL, or already have a running MySQL, and you should have configured, built and installed <B>Bacula</B>. If not, please complete these items before proceeding. <P> Please note that the <B>./configure</B> used to build <B>Bacula</B> will need to include <B><code>--</code>with-mysql=mysql-directory</B>, where <B>mysql-directory</B> is the directory name that you specified on the ./configure command for configuring MySQL. This is needed so that Bacula can find the necessary include headers and library files for interfacing to MySQL. <P> <B>Bacula</B> will install scripts for manipulating the database (create, delete, make tables etc) into the main installation directory. These files will be of the form *_bacula_* (e.g. create_bacula_database). These files are also available in the bacula-src/src/cats directory after running ./configure. If you inspect create_bacula_database, you will see that it calls create_mysql_database. The *_bacula_* files are provided for convenience. It doesn't matter what database you have chosen; create_bacula_database will always create your database. <P> Now you will create the Bacula MySQL database and the tables that Bacula uses. <P> <OL> <LI>Start <B>mysql</B>. You might want to use the <B>startmysql</B> script provided in the Bacula release. <P> </LI> <LI>cd install-directory This directory contains the Bacula catalog interface routines. <P> </LI> <LI>./grant_mysql_privileges This script creates unrestricted access rights for the user <B>bacula</B>. You may want to modify it to suit your situation. Please note that none of the userids, including root, are password protected. If you need more security, please assign a password to the root user and to bacula. The program <B>mysqladmin</B> can be used for this. <P> </LI> <LI>./create_mysql_database This script creates the MySQL <B>bacula</B> database. The databases you create as well as the access databases will be located in install-dir/var/ in a subdirectory with the name of the database, where install-dir is the directory name that you specified on the <B><code>--</code>prefix</B> option. This can be important to know if you want to make a special backup of the Bacula database or to check its size. <P> </LI> <LI>./make_mysql_tables This script creates the MySQL tables used by <B>Bacula</B>. </LI> </OL> <P> Each of the three scripts (grant_mysql_privileges, create_mysql_database and make_mysql_tables) allows the addition of a command line argument. This can be useful for specifying the user and or password. For example, you might need to add <B>-u root</B> to the command line to have sufficient privilege to create the Bacula tables. <P> To take a closer look at the access privileges that you have setup with the above, you can do: <P> <PRE> mysql-directory/bin/mysql -u root mysql select * from user; </PRE> <P> <H1><A NAME="SECTION004230000000000000000"> Re-initializing the Catalog Database</A> </H1> <A NAME="20480"></A> <A NAME="20481"></A> <P> After you have done some initial testing with <B>Bacula</B>, you will probably want to re-initialize the catalog database and throw away all the test Jobs that you ran. To do so, you can do the following: <P> <PRE> cd <install-directory> ./drop_mysql_tables ./make_mysql_tables </PRE> <P> Please note that all information in the database will be lost and you will be starting from scratch. If you have written on any Volumes, you must write an end of file mark on the volume so that Bacula can reuse it. Do so with: <P> <PRE> (stop Bacula or unmount the drive) mt -f /dev/nst0 rewind mt -f /dev/nst0 weof </PRE> <P> Where you should replace <B>/dev/nst0</B> with the appropriate tape drive device name for your machine. <P> <H1><A NAME="SECTION004240000000000000000"> Linking Bacula with MySQL</A> </H1> <A NAME="20489"></A> <A NAME="20490"></A> <A NAME="20491"></A> <P> After configuring Bacula with <P> ./configure <code>--</code>enable-thread-safe-client <code>--</code>prefix=mysql-directory where mysql-directory is in my case <B>/home/kern/mysql</B>, you may have to configure the loader so that it can find the MySQL shared libraries. If you have previously followed this procedure and later add the <B><code>--</code>enable-thread-safe-client</B> options, you will need to rerun the <B>ldconfig</B> program shown below. If you put MySQL in a standard place such as <B>/usr/lib</B> or <B>/usr/local/lib</B> this will not be necessary, but in my case it is. The description that follows is Linux specific. For other operating systems, please consult your manuals on how to do the same thing: <P> First edit: <B>/etc/ld.so.conf</B> and add a new line to the end of the file with the name of the mysql-directory. In my case, it is: <P> /home/kern/mysql/lib/mysql then rebuild the loader's cache with: <P> /sbin/ldconfig If you upgrade to a new version of <B>MySQL</B>, the shared library names will probably change, and you must re-run the <B>/sbin/ldconfig</B> command so that the runtime loader can find them. <P> Alternatively, your system my have a loader environment variable that can be set. For example, on a Solaris system where I do not have root permission, I use: <P> LD_LIBRARY_PATH=/home/kern/mysql/lib/mysql <P> Finally, if you have encryption enabled in MySQL, you may need to add <B>-lssl -lcrypto</B> to the link. In that case, you can either export the appropriate LDFLAGS definition, or alternatively, you can include them directly on the ./configure line as in: <P> <PRE> LDFLAGS="-lssl -lcyrpto" \ ./configure \ <your-options> </PRE> <P> <H1><A NAME="SECTION004250000000000000000"> Installing MySQL from RPMs</A> </H1> <A NAME="20508"></A> <A NAME="20509"></A> If you are installing MySQL from RPMs, you will need to install both the MySQL binaries and the client libraries. The client libraries are usually found in a devel package, so you must install: <P> <PRE> mysql mysql-devel </PRE> <P> This will be the same with most other package managers too. <P> <H1><A NAME="SECTION004260000000000000000"> Upgrading MySQL</A> </H1> <A NAME="20513"></A> <A NAME="20514"></A> <A NAME="20515"></A> If you upgrade MySQL, you must reconfigure, rebuild, and re-install Bacula otherwise you are likely to get bizarre failures. If you install from rpms and you upgrade MySQL, you must also rebuild Bacula. You can do so by rebuilding from the source rpm. To do so, you may need to modify the bacula.spec file to account for the new MySQL version. <P> <HR> <!--Navigation Panel--> <A NAME="tex2html1946" HREF="Installing_Configuring_Post.html"> <IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> <A NAME="tex2html1940" HREF="Bacula_Main_Reference.html"> <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> <A NAME="tex2html1934" HREF="Using_Bacula_Improve_Comput.html"> <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> <A NAME="tex2html1942" HREF="Contents.html"> <IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A> <A NAME="tex2html1944" HREF="Thanks.html"> <IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A> <BR> <B> Next:</B> <A NAME="tex2html1947" HREF="Installing_Configuring_Post.html">Installing and Configuring PostgreSQL</A> <B> Up:</B> <A NAME="tex2html1941" HREF="Bacula_Main_Reference.html">Bacula Main Reference</A> <B> Previous:</B> <A NAME="tex2html1935" HREF="Using_Bacula_Improve_Comput.html">Using Bacula to Improve</A> <B> <A NAME="tex2html1943" HREF="Contents.html">Contents</A></B> <B> <A NAME="tex2html1945" HREF="Thanks.html">Index</A></B> <!--End of Navigation Panel--> <ADDRESS> 2010-06-14 </ADDRESS> </BODY> </HTML>