What should be the
Step 1 for installing MySQL from source. Easy,download the source from MySQL site. Here is the link
MySQL SourceHere is a point, If you are going to work with
storage engine download at least
mysql-5.1 because older versions don't have pluggable storage engine support. In this example I am using mysql-5.1.30 in Fedora 8.
It may take a few minutes to download the source. By the time you get the source downloaded you can read the rest of the article or take a cup of tea or just keep starring at the monitor(that's what I do actually).
Now make sure that you are logged in as superuser(root). Now create an account
mysql.
Step 2# groupadd mysql
# useradd -g mysql mysql
This account(mysql) will have access to manage databases.
Now unpack the downloaded file and cd to it.
Step 3# tar -xzf mysql-5.1.30.tar.gz
# cd mysql-5.1.30
Now configure, make, make install. I usually use the /usr/local/ directory to install mysql.
Step 4# ./configure --prefix=/usr/local/mysql-5.1.30
# make
# make install
Now we have to create a configuration file. It offers several security and control options (here you can limit system resources to be used by MySQL server, set the default collation and character set etc.). No need to make a new configuration file,there are 4 in support-files/ directory. Here we will use my-small.cnf.
Step 5# cp support-files/my-small.cnf /etc/my.cnf
# chown root /etc/my.cnf
# chgrp root /etc/my.cnf
# chmod 644 /etc/my.cnf
Now open the file and add
user = mysql below
[mysqld] Now we have to install the grant tables. Installing the grant tables is accomplished by running the
mysql_install_db script. This creates the mysql database which will hold all database privileges, the test database which you can use to test MySQL, and also privilege entries for the user that run mysql_install_db and a root user (without any passwords).
Step 6# /usr/local/mysql-5.1.30/bin/mysql_install_db --user=mysql
The script will create /usr/local/mysql/var/ directory containing the necessary databases. This directory serves as a default storage for all databases you will create. Make sure it is writable by "mysql" system user!
Now we shall start the server.
Step 7# /usr/local/mysql-5.1.30/bin/mysqld_safe --user=mysql &
This will start the server. To check if really server is running you can check the processes or try checking the mysql version.
# ps -all|grep mysql
# /usr/local/mysql-5.1.30/bin/mysqladmin version
Now connect to mysql server.
Step 8# /usr/local/mysql-5.1.30/bin/mysql -u root
Now you can see that you are connected to mysql. To check all Hosts and users do,
mysql> SELECT Host, User FROM mysql.user;
Right now there is no password for root user,you can put a password for the root user.
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
Query OK, 0 rows affected (0.00 sec)
To exit mysql write
mysql> quit
Now to stop the server,
# /usr/local/mysql-5.1.30/bin/mysqladmin -u root -p shutdown
Now to start it again,
# /usr/local/mysql-5.1.30/bin/mysqld_safe --user=mysql &
Now connect again,
# /usr/local/mysql-5.1.30/bin/mysql -u root -p
You will be now prompted for password and giving the password you are connected to mysql.
If everything is done properly than Congratulations, mysql installation from source is done in your PC.
Appendix:One more thing, If you don't want to start MySQL server manually after each system reboot set up an automatic startup. Go back to the directory where you extracted the downloaded mysql tarball file. Enter
# cp support-files/mysql.server /etc/init.d/mysql
# chmod 755 /etc/init.d/mysql
# chkconfig --add mysql
# chkconfig --level 35 mysql on