Firebird News

Thursday, August 13, 2009

Mysql 5.1.x from source on Ubuntu Jaunty Server x64

I needed to run mysql5.1.x compiled from source , the version from ubuntu is old 5.0.x
and for this i had to do following steps
Follow the download link for mysql

http://dev.mysql.com/downloads/mysql/5.1.html#source

$ sudo apt-get build-dep mysql-server

Download the last source code archives for the mysql :
$ wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.37.tar.gz/from/http://gd.tuwien.ac.at/db/mysql/


$ tar -zxf mysql-5.1.37.tar.gz


$ sudo ./configure --prefix=/opt/mysql5.1.x --localstatedir=/opt/mysql5.1.x --with-plugins=innobase --without-debug --with-mysqld-user=mysql --with-unix-socket-path=/tmp/mysql5.1.x.sock

Create a non-privileged group and user for the database server, as below:

$ sudo groupadd mysql
$ sudo useradd -g mysql mysql

count the number of cpus you have

$ cat /proc/cpuinfo | grep -c processor

4 is in my case (quad core) so i will use it for make argument

$ make -j4

Create data directory and set the right permission on it:

sudo mkdir -p /var/lib/mysql5.1.x
sudo chown mysql.mysql /var/lib/mysql5.1.x

sudo make install
cd /opt/mysql5.1.x/bin/


sudo ./mysql_install_db --datadir=/var/lib/mysql5.1.x --user=mysql

Copy the init script from to the source directory mysql-5.1.37

sudo cp support-files/mysql.server /etc/init.d/mysql-5.1.x

modify this variable
datadir=/var/lib/mysql5.1.x
in the start-up script

$sudo pico /etc/init.d/mysql-5.1.x

add the script at startup

$ cd /etc/init.d
$ sudo chmod +x mysql-5.1.x
$ sudo update-rc.d mysql-5.1.x defaults

Start mysql server
$sudo /etc/init.d/mysql-5.1.x start

Connect to mysql server
/opt/mysql5.1.x/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.37 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


Set password for root user

/opt/mysql5.1.x/bin/mysql -u root
mysql> UPDATE mysql.user SET Password = PASSWORD('newpwd')
-> WHERE User = 'root';
mysql> FLUSH PRIVILEGES;


Remove the anonymous accounts

mysql> use mysql
mysql> delete from user where user='';

No comments: