MySQL Database Installation and configuration

by Prabakaran 2012-08-01 14:49:38

Red Hat / Fedora Core RPM Packages:

mysql-version.rpm (Required)
mysql-server-version.rpm (Required)
mysqlclient9-version.rpm (Shared object libraries)
mysql-devel-version.rpm (C include files and libraries for developers)
php-mysql-version.rpm (For accessing MySQL database from php)

Install: rpm -ivh mysql-version.rpm mysql-server-version.rpm mysqlclient9-version.rpm
Check if installed: rpm -q mysql mysql-server mysqlclient9
The examples on this page used mySQL 3.23.58 which is used in Red Hat 7, 8, 9 and Fedora Core 1, 2, 3.
Also see YoLinux.com systems administration - using RPM to set GPG signatures and install RPM packages.

Installing MySQL.com RPM packages: If instaling newer versions of MySQL from RPM packages obtained from MySQL.com, you must first import and register their public GPG key:

Download public key named build@mysql.com from http://www.keyserver.net/ with one of two methods:
wget --output-document=pubkey_mysql.asc http://keyserver.veridis.com:11371/export?id=-8326718950139043339
(Saves key 0x5072E1F5 as file pubkey_mysql.asc)
gpg --keyserver keyserver.veridis.com --recv-key 5072e1f5
gpg --export -a 5072e1f5 > pubkey_mysql.asc
Import key: rpm --import pubkey_mysql.asc

[Potential Pitfall]: Your system should have a host name other than the default "localhost". Give your systems a host name if you get the following installation error:

ERROR: 1062 Duplicate entry 'localhost-root' for key 1
ERROR: 1062 Duplicate entry 'localhost-' for key 1

Use the command hostname to give your system a hostname and also set in the configuration file /etc/sysconfig/network

Ubuntu / Debian package installation:

apt-get install mysql-client
apt-get install mysql-server

Start the database:

Start the database: /etc/rc.d/init.d/mysqld start
(The script will run mysql_install_db to create a default database in /var/lib/mysql/mysql/ if the mysql init script has never been run before. The install script will not be run again as long as the default database directory exists.)
The database executes as user mysqld and group mysqld.

Notes:

One may manually initialize the database with the command: /usr/bin/mysql_install_db
Creates system tables in /var/lib/mysql/mysql/
Only execute the first time MySQL is installed.
Databases located in: /var/lib/mysql/
Default config file installed by RPM: /etc/my.cnf
(Ubuntu: /etc/mysql/my.cnf)

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

[mysql.server]
user=mysql
basedir=/var/lib

[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
948
like
0
dislike
0
mail
flag

You must LOGIN to add comments