Installing MySQL from source on linux

IDANCE

New Member
DOWNLOAD AND COMPILE



PHP Code: \[code\]cd /usr/local/src 
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.25-rc.tar.gz/from/http://mysql.he.net/ 
tar -zxvf mysql-5.1.25-rc.tar.gz 
cd mysql-5.1.25-rc 
./configure --prefix=/usr --enable-assembler --with-innodb 
make 
make install 
\[/code\] CREATE mysql USER


On ssh prompt, run



PHP Code: \[code\]groupadd mysql 
useradd -g mysql -d /var/lib/mysql mysql 
\[/code\] Create log file


PHP Code: \[code\]touch /var/log/mysqld.log 
chown mysql:mysql /var/log/mysqld.log 
chown -R mysql:mysql /backup/mysql 
\[/code\] init SCRIPT

PHP Code: \[code\]      cp support-files/mysql.server /etc/rc.d/init.d/mysql 
chmod 755 /etc/rc.d/init.d/mysql 
\[/code\] CREATING /etc/my.cnf

Before you can start mysql, you need to create my.cnf gile



PHP Code: \[code\] vi /etc/my.cnf 
\[/code\] I have mysql data folder in /backup/mysql (default location is /var/lib/mysql), on my server my.cnf is

PHP Code: \[code\]      [root@server52 php-5.2.6]# cat /etc/my.cnf 
[mysqld] 
datadir=/backup/mysql 
socket=/backup/mysql/mysql.sock 

[mysql.server] 
user=mysql 

[mysqld_safe] 
log-error=/var/log/mysqld.log 
pid-file=/var/run/mysqld/mysqld.pid 

[mysql] 
socket=/backup/mysql/mysql.sock 

[root@server52 php-5.2.6]# 
\[/code\]
CREATE INITIAL DATABASE

Now create the initial database with



PHP Code: \[code\] ./scripts/mysql_install_db 
\[/code\] Here is what you get on running the command.
PHP Code: \[code\]     
      [root@server52 mysql-5.1.23-ndb-6.2.15]# ./scripts/mysql_install_db 
Installing MySQL system tables... 
OK 
Filling help tables... 
OK 

To start mysqld at boot time you have to copy 
support-files/mysql.server to the right place for your system 

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! 
To do so, start the server, then issue the following commands: 

/usr/bin/mysqladmin -u root password 'new-password' 
/usr/bin/mysqladmin -u root -h server52.hosthat.com password 'new-password' 

Alternatively you can run: 
/usr/bin/mysql_secure_installation 

which will also give you the option of removing the test 
databases and anonymous user created by default.  This is 
strongly recommended for production servers. 

See the manual for more instructions. 

You can start the MySQL daemon with: 
cd /usr ; /usr/bin/mysqld_safe & 

You can test the MySQL daemon with mysql-test-run.pl 
cd /usr/mysql-test ; perl mysql-test-run.pl 

Please report any problems with the /usr/bin/mysqlbug script! 

The latest information about MySQL is available at http://www.mysql.com/ 
Support MySQL by buying support/licenses from http://shop.mysql.com/ 

[root@server52 mysql-5.1.23-ndb-6.2.15]# 
\[/code\]




STARTING MySQL

To start MySQL run



PHP Code: \[code\] /etc/rc.d/init.d/mysql start 
\[/code\] If you have any problem with mysql startup, run



PHP Code: \[code\] /bin/sh -x /etc/rc.d/init.d/mysql start 
\[/code\] This will give you detailed information on what the start up script is doing and help you to fix the problem.

Also check the file /var/log/mysqld.log
STARTING MySQL ON BOOT

Run following commands to start MySQL on boot.

PHP Code: \[code\]chkconfig --add mysql 
chkconfig mysql on 
chkconfig --list mysql 
\[/code\] Or you can enable mysql on graphical interface with command

ntsysv

START/STOP MySQL

PHP Code: \[code\]service mysql stop 
service mysql start 
\[/code\] You can also use the init script directly.

PHP Code: \[code\]      [root@server52 ~]# /etc/init.d/mysql 
Usage: /etc/init.d/mysql  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ] 
[root@server52 ~]# 
\[/code\]


AVOID MYSQL OVERWRITE BY YUM

When you install some program from yum (for example yum install exim) will install mysql also, will over write your existing MySQL installation.

To avoid happening this, edit /etc/yum.conf, add following line just below [main]



PHP Code: \[code\] exclude=mysql* 
\[/code\]



PHP Code: \[code\]echo "/usr/lib/mysql" >> /etc/ld.so.conf 
ldconfig 
ldconfig -p|grep mysql 
\[/code\]
 
Top