The basic commands you must execute to install a MySQL source distribution are:
shell> groupadd mysql shell> useradd -g mysql mysql shell> gunzip < mysql-VERSION.tar.gz | tar -xvf - shell> cd mysql-VERSION shell> ./configure --prefix=/usr/local/mysql shell> make shell> make install shell> scripts/mysql_install_db shell> chown -R root /usr/local/mysql shell> chown -R mysql /usr/local/mysql/var shell> chgrp -R mysql /usr/local/mysql shell> cp support-files/my-medium.cnf /etc/my.cnf shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &
If your version of MySQL is older than 4.0, use safe_mysqld
rather than mysqld_safe
.
If you want to have support for InnoDB tables, you should edit the
/etc/my.cnf
file and remove the #
character before the
parameter that starts with innodb_...
.
See section 4.1.2 `my.cnf' Option Files, and section 7.5.3 InnoDB Startup Options.
If you start from a source RPM, do the following:
shell> rpm --rebuild --clean MySQL-VERSION.src.rpm
This will make a binary RPM that you can install.
You can add new users using the bin/mysql_setpermission
script if
you install the DBI
and DBD-mysql
Perl modules.
A more detailed description follows.
To install a source distribution, follow these steps, then proceed to section 2.4 Post-installation Setup and Testing, for post-installation initialisation and testing:
BDB
or BerkeleyDB
Tables.
MySQL source distributions are provided as compressed tar
archives and have names like `mysql-VERSION.tar.gz', where
VERSION
is a number like 4.1.1-alpha.
mysqld
to run as:
shell> groupadd mysql shell> useradd -g mysql mysqlThese commands add the
mysql
group and the mysql
user. The
syntax for useradd
and groupadd
may differ slightly on different
versions of Unix. They may also be called adduser
and addgroup
.
You may wish to call the user and group something else instead of mysql
.
shell> gunzip < /path/to/mysql-VERSION.tar.gz | tar xvf -This command creates a directory named `mysql-VERSION'.
shell> cd mysql-VERSIONNote that currently you must configure and build MySQL from this top-level directory. You cannot build it in a different directory.
shell> ./configure --prefix=/usr/local/mysql shell> makeWhen you run
configure
, you might want to specify some options.
Run ./configure --help
for a list of options.
section 2.3.3 Typical configure
Options, discusses some of the
more useful options.
If configure
fails, and you are going to send mail to
mysql@lists.mysql.com to ask for assistance, please include any
lines from `config.log' that you think can help solve the problem. Also
include the last couple of lines of output from configure
if
configure
aborts. Post the bug report using the mysqlbug
script. See section 1.7.1.3 How to Report Bugs or Problems.
If the compile fails, see section 2.3.5 Problems Compiling MySQL?, for help with
a number of common problems.
shell> make installYou might need to run this command as
root
.
shell> scripts/mysql_install_dbNote that MySQL versions older than Version 3.22.10 started the MySQL server when you run
mysql_install_db
. This is no
longer true.
root
and ownership of the data
directory to the user that you will run mysqld
as:
shell> chown -R root /usr/local/mysql shell> chown -R mysql /usr/local/mysql/var shell> chgrp -R mysql /usr/local/mysqlThe first command changes the
owner
attribute of the files to the
root
user, the second one changes the owner
attribute of the
data directory to the mysql
user, and the third one changes the
group
attribute to the mysql
group.
DBI
/DBD
interface,
see section 2.7 Perl Installation Comments.
support-files/mysql.server
to the location where
your system has its startup files. More information can be found in the
support-files/mysql.server
script itself and in
section 2.4.3 Starting and Stopping MySQL Automatically.
After everything has been installed, you should initialise and test your distribution:
shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &
If that command fails immediately with mysqld daemon ended
, you can
find some information in the file `mysql-data-directory/'hostname'.err'.
The likely reason is that you already have another mysqld
server
running. See section 4.1.3 Running Multiple MySQL Servers on the Same Machine.
Now proceed to section 2.4 Post-installation Setup and Testing.
Posted by Matt Juszczak on Saturday June 8 2002, @3:13pm | [Delete] [Edit] |
If you forget to do --prefix=/usr/local/mysql
during configure, your distribution will install
into /usr/local. Rerunning configure with the --
prefix=/usr/local/mysql seemed to make the
installation go into /usr/local/mysql, but the
script "mysql_install_db", etc...seemed to
require the --basedir argument, and SQL wouldn't
start. So if you forget to do --
prefix=/usr/local/mysql, clear out all configure
logs/caches before rerunning ./configure.
Posted by [name withheld] on Wednesday November 20 2002, @4:12am | [Delete] [Edit] |
Could the first two steps be omitted?If I 'm not a
system administrator,could I install MYSQL into
my own directory successfully?Thanks!
Posted by Matt Gregory on Thursday March 13 2003, @8:36am | [Delete] [Edit] |
Before following Mr. Juszczak's suggestion above I suggest that you do the following...
If you realize that you did not add the --prefix argument, then you may simply continue without changing anything. /usr/local is a perfectly acceptable place to install mysql. If you would rather do things *exactly* by the book, then before you go back and reconfigure as he suggests, do the following (make sure you are in the mysql src directory and logged in as root (or using sudo) first):
<pre>
make uninstall
make distclean
</pre>
The command uninstall directive tells make to go and remove all the files and directories created with the install directive. This will (hopefully) clean up mysql from /usr/local.
The distclean directive tells make to not only delete all the compiled files but to also remove any config.cache, config.log or config.status information. Basically return the sourcetree to it's state just after untaring it.
Good, luck, have fun, and when all else fails stop by #linuxhelp on your favorite IRC network (I recommend EFnet and Undernet).