Installing MySQL from source on linux

Status
Not open for further replies.

Albert.Nawaro

Active Member
88
2012
4
0
DOWNLOAD AND COMPILE



PHP:
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
CREATE mysql USER


On ssh prompt, run



PHP:
groupadd mysql 
useradd -g mysql -d /var/lib/mysql mysql

Create log file


PHP:
touch /var/log/mysqld.log 
chown mysql:mysql /var/log/mysqld.log 
chown -R mysql:mysql /backup/mysql

init SCRIPT

PHP:
      cp support-files/mysql.server /etc/rc.d/init.d/mysql 
chmod 755 /etc/rc.d/init.d/mysql
CREATING /etc/my.cnf

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



PHP:
 vi /etc/my.cnf

I have mysql data folder in /backup/mysql (default location is /var/lib/mysql), on my server my.cnf is

PHP:
      [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]#


CREATE INITIAL DATABASE

Now create the initial database with



PHP:
 ./scripts/mysql_install_db

Here is what you get on running the command.
PHP:
      [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]#






STARTING MySQL

To start MySQL run



PHP:
 /etc/rc.d/init.d/mysql start

If you have any problem with mysql startup, run



PHP:
 /bin/sh -x /etc/rc.d/init.d/mysql start

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:
chkconfig --add mysql 
chkconfig mysql on 
chkconfig --list mysql
Or you can enable mysql on graphical interface with command

ntsysv

START/STOP MySQL

PHP:
service mysql stop 
service mysql start
You can also use the init script directly.

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



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:
 exclude=mysql*




PHP:
echo "/usr/lib/mysql" >> /etc/ld.so.conf 
ldconfig 
ldconfig -p|grep mysql
 
Status
Not open for further replies.
Back
Top