Monday, October 4, 2010

MySQL Configuration using source file on Linux

Get the Mysql Source Code from following location
http://downloads.mysql.com/archives.php
Unpack the Source Code in /usr/local/src/ direcotry
# tar xzf /usr/local/src/mysql-version.tar.gz
Build and Install MySQL
add user and group mysql
# groupadd mysql # useradd -g mysql -c "MySQL Server" mysql
# cd /usr/local/src/mysql-version/
# chown -R root.root *
#./configure --prefix=/usr/local/mysql-vesion
# make
# make install
Then create a symbolic link 'mysql' pointing to mysql-5.x.x(Installation directory)
# ln -s /usr/local/mysql-version/ /usr/local/mysql
(Generally mysql installation path is /usr/local/mysql)
Create mysql configuration file from sample file included in mysql package
MySQL comes with four sample configuration files from which to choose depending on your system and database size:
/etc/my-huge.cnf
/etc/my-large.cnf
/etc/my-medium.cnf
/etc/my-small.cnf
Select appropriate file for your server
# cp mysql-5.x.x/support-files/my-small.cnf /etc/my.cnf
Create the MySQL privilege database by executing the script /usr/local/mysql/bin/mysql_install_db
This includes the host, user,tables_priv, columns_priv, and func tables which manage user access to your databases.
#./usr/local/mysql/bin/mysql_install_db --user=mysql
Start the server
#/usr/local/mysql/bin/mysqld_safe --user=mysql &
Now create a startup script, which enables MySQL auto-start each time your server is restarted.
# cp .mysql-version/support-files/mysql.server /etc/rc.d/init.d/mysql
# chmod +x /etc/rc.d/init.d/mysql
# /sbin/chkconfig --level 3 mysql on
Creating a MySQL "root" Account

Use the mysqladmin command to set the MySQL root password. The syntax is as follows: # mysqladmin -u root password new-password
Test MySQL
To run a quick test, use the command line program mysql:
# mysql -u root -p
and enter your new root user password when prompted. You will then see the MySQL prompt:
mysql>

No comments:

Post a Comment