MySQL AB advises that the best way to install MySQL on Linux is to use an RPM (Red Hot Package Manager) and the MySQL web site provides a number of RPMs in case.
The RPMs, by default, will install the applications within the /var/lib/mysql directory. Further, the RPM will add the requisite data to the /etc/rc.d/ directory so that the MySQL server daemon will be automatically started when the computer is booted.
- access the server via command-line interface (Terminal)
- use the root access for this
- go to the /usr/local directory
ex.:
cd /usr/local
- download the MySQL binary or source distribution
- move the downloaded files to /usr/local via browser
- or use wget or curl to immediately download the file to the current directory
- unpack the files
ex.:
gunzip mysql-3.23.49.tar.gz
tar xvf mysql-3.23.49.tar
- create a link referring to this directory
ex.:
ln -s /usr/local/mysql-3.23.49mysql
- create a new MySQL user and group
ex.:
groupadd mysql
useradd -g mysql mysql
- move into the new mysql directory
ex.:
cd mysql
- configure the MySQL directory
ex.:
./configure --prefix=/usr/local/mysql
If you are using the MySQL source, as opposed to the binary, you will ned to configure it yourself, then make the install the files(see next two(2) steps). If you are using a precompiled binary, you can skip this and the next two(2) steps.
- after configuration has run
- make and install the files
ex.:
make
make install
install the default databases
ex.:
scripts/mysql_install_db
- change the permission on the new files
ex.:
chown -R root /usr/local/mysql/.
chown -R mysql /usr/local/mysql/data
chown -R mysql /usr/local/mysql/.
This final step allows the MySQL server to run under the guise of the newly created mysql user
|