MySQL DBA Tips Corner |
|
Installing MySQL 3.23 - (Linux)
by Jeff Hunter, Sr. Database Administrator
Contents
Overview
I typically install MySQL in /usr/local/mysql as the UNIX root account.
I then create a UNIX mysql account that will have access to manage databases.
Once you've installed MySQL, you will need to initialize the grant tables, start
the server, and make sure that the server works okay. You may also elect to arrange
for the server to be started and stopped automatically when your system starts up
and shuts down.
Installing the grant tables is accomplished by running the
Operating System Account
Create MySQL UserID:
Uncompress / Installing Binary Version of MySQL
Starting and Stopping the MySQL Database Software
Open
This error will be fixed for MySQL 3.23.54a, which will be released shortly.
Testing the Installation
Starting the MySQL Database
.bash_profile For The mysql User Account
Copyright (c) 1998-2012 Jeffrey M. Hunter. All rights reserved.
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter
and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express,
prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate,
but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from
relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.
The following article provides the steps necessary to successfully install
the binary version of MySQL, release 3.23, on RedHat Linux 8.0. These procedures
should work as well on versions of RedHat as early as version 6.2.
mysql_install_db
script. This creates the mysql database which will hold all database privileges,
the test database which you can use to test MySQL, and also privilege entries for
the user that run mysql_install_db and a root user
(without any passwords).
Create MySQL User Account:
% groupadd -g 116 mysql
% useradd -u 174 -c "MySQL Software Owner" \
-d /u01/app/mysql -g "mysql" -m -s /bin/bash mysql
% passwd mysql
% mkdir /u01
% mkdir /u01/app
% mkdir /u01/app/mysql
% chown -R mysql:mysql /u01/app/mysql
% su -
% cp mysql-3.23.54-pc-linux-i686.tar /usr/local
% cd /usr/local
% gunzip mysql-3.23.54-pc-linux-i686.tar.gz
% tar xvf mysql-3.23.54-pc-linux-i686.tar
% ln -s mysql-3.23.54-pc-linux-i686 mysql
% cd mysql
% scripts/mysql_install_db
% chown -R root .
% chown -R mysql data
% chgrp -R mysql .
Starting the MySQL Database
% bin/safe_mysqld --user=mysql &
Stopping the MySQL Database
% bin/mysqladmin -u root shutdown
NOTE:
The safe_mysqld startup
script of MySQL 3.23.54 includes a small bug that leads to a "syntax error"
message on startup. Here is a quick hint on how to fix it:
bin/safe_mysqld with a text editor. Go to line 162 and look
for the following text:
if $NOHUP_NICENESS -gt 0
then
$NOHUP_NICENESS="nice --$NOHUP_NICENESS nohup"
Change it to look like this:
if test $NOHUP_NICENESS -gt 0
then
NOHUP_NICENESS="nice --$NOHUP_NICENESS nohup"
(Make sure to add "test" to the if-statement and remove
the dollar sign from the $NOHUP_NICENESS= line)
Ensure that the MySQL Software, the
mysqld server, is running and you
have set up the initial MySQL grant tables containing the privileges that determine
how users are allowed to connect to the server. This is normally done with the
mysql_install_db script.
mysqladmin
% mysqladmin ping
mysqld is alive
% mysqladmin version
mysqladmin Ver 8.23 Distrib 3.23.54, for pc-linux on i686
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version 3.23.54
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 59 min 45 sec
Threads: 1 Questions: 2 Slow queries: 0
Opens: 6 Flush tables: 1 Open tables: 0
Queries per second avg: 0.001
% bin/safe_mysqld --user=mysql &
Stopping the MySQL Database
% bin/mysqladmin -u root shutdown
% mysqlshow
+-----------+
| Databases |
+-----------+
| mysql |
| test |
+-----------+
% mysqlshow -u root mysql
Database: mysql
+--------------+
| Tables |
+--------------+
| columns_priv |
| db |
| func |
| host |
| tables_priv |
| user |
+--------------+
% mysql -u root -e "select host, db, user from db" mysql
+------+---------+------+
| host | db | user |
+------+---------+------+
| % | test | |
| % | test\_% | |
+------+---------+------+
% mysql -u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15 to server version: 3.23.54
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> select host, db, user from db;
+------+---------+------+
| host | db | user |
+------+---------+------+
| % | test | |
| % | test\_% | |
+------+---------+------+
2 rows in set (0.00 sec)
.bash_profile
# +------------------------------------------------------------+
# | FILE : .bash_profile |
# +------------------------------------------------------------+
# +------------------------------------------------------------+
# | GET THE ALIASES AND FUNCTIONS |
# +------------------------------------------------------------+
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# +------------------------------------------------------------+
# | SOURCE GLOBAL DEFINITIONS |
# +------------------------------------------------------------+
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# +------------------------------------------------------------+
# | GET THE ALIASES AND FUNCTIONS |
# +------------------------------------------------------------+
umask 022
EDITOR=vi; export EDITOR
TERM=xterm; export TERM
TMPDIR=/tmp; export TMPDIR
alias ls="ls -FA"
alias s="screen -DRRS iPad -t iPad"
# +------------------------------------------------------------+
# | SETUP SEARCH PATH |
# +------------------------------------------------------------+
PATH=/usr/local/mysql/bin:/usr/local/mysql/support-files:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/java/bin:.
export PATH
# +------------------------------------------------------------+
# | SETUP JAVA ENVIRONMENT (optional) |
# +------------------------------------------------------------+
JAVA_HOME=/usr/local/java
export JAVA_HOME
CLASSPATH=.
CLASSPATH=${CLASSPATH}:/u01/app/oracle/product/9.2.0/jdbc/lib/ojdbc14.jar
export CLASSPATH
# +------------------------------------------------------------+
# | FINISH OFF THE SCRIPT |
# +------------------------------------------------------------+
echo ".bash_profile executed for user $USER"
Wednesday, 30-Jun-2010 14:30:04 EDT
Page Count: 8256