Very often people not expert ask me some simple detailed directions on how to install MySQL from fresh.

The following is a simple one that if you will follow step by step should give you a MySQL working installation.

this articule assume that you have the possibility to attach different storage for:

System and binaries




1) You need to have access to the client area for download the MySQL software from somwere possible points are:

2) Perl DBI and DBD::mysql installed on the machine (See How to Install MySQL Perl module guide)

3) Root privileges



1) Install the Perl modules

2) Create a directory layout as follow:

|-- data
| |-- mysql
| `-- test
`-- lost+found

|-- exports
`-- logs
|-- Q_MySQL
    |-- binlog
    |-- general
    |-- innodb
`-- relay


3) Create a directory for the MySQL binary in:



4) Expand the downloaded file (MySQL server binary installation) into the mysqldistributions directory


5) Create the symbolic link to /usr/local/mysql


6) Copy the file from /usr/local/mysql/support-files/mysql.server to /etc/init.d/ as mysql


7) Register it chkconfig –-add mysql


8) Create in /etc/ the file my.cnf and modify the server-id with a unique value


9) Create the group and user mysql

groupadd mysql
seradd -g mysql –s /bin/bash –p mysql


10) Change the permissions on all the relevant directories:

chown –R mysql:mysql /mysql_logs
chown –R mysql:mysql /mysql_data
chown –R mysql:mysql /usr/local/mysql*


11) Impersonate the user mysql su –l mysql


12) Run the script to initialize the mysql database

./scripts/./mysql_install_db --basedir=/usr/local/mysql --datadir=/mysql_data/data


13) Check that the directories are created and the permissions correctly set:

ll /mysql_data/data

14) Open another terminal window to check the log


15) Become root again


16) Start the MySQL server with

/etc/init.d/mysql start


17) On the opened terminal type:

tail -fn200 /mysql_data/data/.err to check what is going on


18) On the original terminal, go inside the mysql server using the local

mysql console: /usr/local/mysql/bin/mysql –uroot

19)Check for anonymous user to remove

root@localhost:mysql.sock [(none)]> select user,host from mysql.user;


| user | host |
| root | |
| | localhost |
| root | localhost |
| | |
| root | |

5 rows in set (0.00 sec)
and remove them:

root@localhost:mysql.sock [(none)]> drop user ''@localhost;
root@localhost:mysql.sock [(none)]> drop user ''@’machinename’;

    Add the Password for the user root for *ANY* hosts:
set password for root@localhost=Password('mysql');
set password for root@’machinename’=Password('mysql');

set password for root@’’=Password('mysql');


20) Exit and try if all was done correctly:

root@localhost:mysql.sock [(none)]> exit


[root@xx mysql]# /usr/local/mysql/bin/mysql -uroot -pmysql

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.1.31sp1-enterprise-gpl-pro-log MySQL Enterprise Server - Pro Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

root@localhost:mysql.sock [(none)]>


21)Now add al the other user as you like