MySQL II : Fedora MySQL Installation

Install MySQL 5.0 on Fedora 4

1. You’ll need to be starting from a machine that has MySQL 4.x clients and development libraries installed. For this class we’re using Fedora 4 linux boxes, so we’re using RPM installations and defaults.

Earlier versions of MySQL appear in the RPM libraries with the spelling (lowercase) “mysql” instead of the later “MySQL” (uppercase) spelling; try the lowercase versions first. Run this query:

rpm -q mysql

rpm -q mysql-server

If you get a match, and the version is 4.0 or later, skip the next two. If you don’t get a match, run these:

rpm -q MySQL-client

rpm -q MySQL-server

If you still don’t get a match, get and install MySQL 4.0 or later via RPM or installation CD.

You will need a version that includes the file libmysqlclient.so.14, which in my experience means 4.0 or later. Your results may vary. Just be sure you have this file.

Once you do have the mysql (or MySQL) packages installed, check for these. They’ll make life simpler later on.

rpm -q MySQL-python

rpm -q MySQL-devel

rpm -q MySQL-shared

 

2. Prepare for the upgrade.

Go to the /usr/lib directory. You’ll have a mysql directory. Copy it. The name you choose is irrelevant; backing up this directory is critical.

Also, make a copy of /etc/my.cnf. RPM package removal did not, in my case, delete this file, but you will need it for a template later, so back it up regardless.

If your installed version of MySQL 4.x is like mine, you’ll see that the server and data previously installed in /var/lib/ and /var/lib/mysql, respectively. While you can leave your datadir defined as /var/lib/mysql (or change it to whatever you want), you must COMMENT OUT the basedir line:

basedir-/var/lib

to this:

#basedir=/var/lib

If you don’t, your installation flatly will not work. MySQL 5 installs its binaries in /usr/lib/mysql (the basedir).

 

3. Uninstall MySQL 4.x:

rpm -e mysql

rpm -e MySQL-client

rpm -e MySQL-server

 

4. Install MySQL 5.0 and its development headers and libraries.

Now get MySQL proper. The latest, by far greatest release is 5.0/5.1, as of this writing  (11/30/2005).

  • static vs. dynamic libraries
  • source vs. binary distributions
  • .tgz vs. .rpm
  • processors

    A. Go to http://dev.mysql.com/downloads/mysql/5.0.html (5.0 is the current stable release) and get the MySQL 5.0 client and server RPMs from the Linux x86 generic RPM downloads section.

    Also get the mysql-devel package (it’s labeled “Libraries and header files“).

    B. Install the RPMs.

    rpm -i <rpmfile>  #substitute the rpm files’ names

    RPMs will install MySQL 5 binaries in /usr/lib/mysql/ by default. in /var/lib/mysql, and will put startup scripts in the /etc/rc.d directory. (Who owns /var/lib/mysql?)

    You are going to get an error message that you are missing a shared library: libmysqlclient.so.14.

C. Remember the /usr/lib/mysql directory that you copied? Restore the files it contains (I’d copy, so I could keep this resource directory) back to the new /usr/lib/mysql directory. You’ve physically restored libmysqlclient.so.14; now you have to re-register it.

Open the file /etc/ld.so.conf . Add the line:

/usr/lib/mysql/libmysqlclient.so.14

Save and close the file.

Run the command:

ldconfig

This loads the library back into the active system configuration.

(How do you find solutions like this? I went straight to the MySQL forum:

User Mike Rappe wrote:

I installed Fedora Core 4 which installed MSQL 4.1.11. I needed the features in ver 5 so I installed it from RPM MySQL-server-5.0.15-0.i386.rpm but I got errors about libmysqlclient.so.14 being needed so I installed MySQL-shared-standard-4.1.15-0.rhel3 and was able to install MySQL-server-5.0.15-0.i386.rpm without any errors. This was the command I used:

rpm -Uhvv MySQL-server-5.0.15-0.i386.rpm

Lenz Grimmer <lenz at (@) mysql dot (.) com> provided the solution:

It seems like the original Red Hat MySQL RPM left a /etc/my.cnf file around – it contains a line that changes “basedir” to /var/lib, which causes the startup script to look for the binaries at the wrong location. Please either comment out that basedir variable or remove /etc/my.cnf completely, if you have not further customized it yet. Better start with a fresh one from scratch. Our RPMs don’t ship with a /etc/my.cnf file by default, but they honour an existing one.

This did the trick for me!)

3. Set the root user’s password for MySQL:

msqladmin -u root password ‘private’

4. Create a user configuration file for root:

vi ~/.my.cnf

Containing this texti:

[client]
password=’private’

 

Return to Intermediate MySQL Home Page

 

Go to http://dev.mysql.com/downloads/mysql/ get MySQL server and client. Copy or move both to /usr/local/ and unpack them:

tar -zxvf mysql-standard-<version>.tar.gz
tar -zxvf mysql-client-<version>.tar.gz

You’ll end up with a directories named like mysql-standard-<version>.tar.gz_FILES. I prefer to cd into these and then move the mysql-standard-<version> directories up outside it, and delete the _FILES directories.

Create symbolic links to the new directories:

ln –s /usr/local/mysql-<version> mysql

Create a mysql user and group:

useradd mysql
<enter a password, twice>

Move to the MySQL directory:

cd mysql

Configure and install:

./configure –prefix=/usr/local/mysql

Note that if you install MySQL 5.0 or later this way, you will not run the following two commands.

make
make install

Install the default databases:

cd /usr/local/mysql/scripts
./mysql_install_db
cd ..

Change the permissions on the new files, which allows MySQL to run as the new mysql user that you created earlier:

chown –R root /usr/local/mysql/
chown –R mysql /usr/local/mysql/data
chgrp –R mysql /usr/local/mysql/

2. If you will be adding Python, also get the mysql-devel package (it’s labeled “Libraries and header files”).