0% found this document useful (0 votes)
10 views

Plugin Mysql

Uploaded by

Jaga Deesh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Plugin Mysql

Uploaded by

Jaga Deesh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

mysql installation and configuration guide on PolyU Academic

Unix Cluster Server hkpu10

Objective:

This guide provides a general guideline for users who would like to install mysql server
in Hong Kong Polytechnic University‟s Academic Unix Cluster Servers which are
running Solaris 10.

1. Pre-requisites:

1.1 Download source from mysql website

 version : 5.1.37 or later


 web site : http://dev.mysql.com/downloads/mysql/5.1.html#solaris
 Under section “Solaris (TAR packages) downloads”, choose to download
version: Solaris 10 (Sparc, 32-bit)

 The filename should be: mysql-5.1.37-solaris10-sparc.tar.gz and file size


about 150 MB.
 Please check that you have sufficient disk quota for mysql installation. You
should have at least 600 MB free disk space available on your academic
unix cluster account.

1.2 Use SCP to transfer the mysql source (downloaded in step 1.1) into the
academic unix server hkpu10.

( Please read the document “SCP User Manual For Academic Unix Cluster”
for how to upload files into academic unix servers.

Created by ITS Page 1 Updated on 9-Sep-2009


https://mydoc.polyu.edu.hk/documents/ssh_scp/scp_for_AUC.pdf )

1.3 Use SSH login hkpu10.polyu.edu.hk with your NetID & NetPassword.
You will need below information during the installation process.

 <netid> = your netid (e.g. ittest)


 <home dir> = your home directory (e.g. /rhome2/it/ittest); you can type
“pwd” to get your home directory after you login the server
 <port num> = a port assigned for your mysql server ; suggestion for port
number : 40000-41000. Please run below command to check if a port is
available for your use:

hkpu10% netstat –na |grep <port num>


LISTEN = unavailable
For example, to check port 40000‟s availability:
hkpu10% netstat -na | grep 40000
*.40000 *.* 0 0 24576 0 LISTEN

Do not use port in “LISTEN” state since there is service running on that
port and thus it is unavailable for use. Please choose other port for your mysql
service.

Example output for available port:


hkpu10% netstat -na | grep 40010
hkpu10%

2. Installation

2.1 Extract the source file


hkpu10% cd
hkpu10% ls –ltr
hkpu10% ls –ltr
-rw----r-- 1 ittest it 157886918 Aug 22 11:07 mysql-5.1.37-solaris10-sparc.tar.gz
hkpu10% gzip -d mysql-5.1.37-solaris10-sparc.tar.gz
hkpu10% tar xvf mysql-5.1.37-solaris10-sparc.tar
2.2 Make a symbolic link
hkpu10% ln –s mysql-5.1.37-solaris10-sparc mysql
hkpu10% ls –l mysql

Check the symbolic link to mysql package is correct


hkpu10% ls -l mysql
lrwxrwxrwx 1 ittest it 42 Aug 22 mysql -> mysql-5.1.37-solaris10-sparc

2.3 Running the installation under your own directory with your own user right
hkpu10% cd mysql

Created by ITS Page 2 Updated on 9-Sep-2009


hkpu10% ./scripts/mysql_install_db --user=<netid>

3. Configuration

3.1 Edit file: <home dir>/mysql/support-files/mysql.server

hkpu10% vi <home dir>/mysql/support-files/mysql.server

Look for the following parameter setting (located at line 46-47):

basedir=
datadir=

Edit the parameter:

basedir=<home dir>/mysql
datadir=<home dir>/mysql/data

3.2 Create a file called my.cf


hkpu10% cd <home dir>/mysql/support-files
hkpu10% cp –p my-small.cnf <home dir>/mysql/data/my.cnf

3.3 Edit my.cnf (Make changes for the red part)

hkpu10% vi <home dir>/mysql/data/my.cnf


# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /usr/local/mysql/data) or
# ~/.my.cnf to set user-specific options.
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients


[client]
#password = your_password
port = <port num>
socket = <home dir>/mysql/data/mysql.sock
# Here follows entries for some specific programs

# The MySQL server


[mysqld]
port = <port num>
socket = <home dir>/mysql/data/mysql.sock
skip-locking
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4

Created by ITS Page 3 Updated on 9-Sep-2009


sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K

# Don't listen on a TCP/IP port at all. This can be a security enhancement,


# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (using the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking
server-id =1

# Uncomment the following if you want to log updates


#log-bin

# Uncomment the following if you are NOT using BDB tables


#skip-bdb

# Uncomment the following if you are using InnoDB tables


#innodb_data_home_dir = /usr/local/mysql/data/
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /usr/local/mysql/data/
#innodb_log_arch_dir = /usr/local/mysql/data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[isamchk]
key_buffer = 8M
sort_buffer_size = 8M

[myisamchk]
key_buffer = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout

4. Startup and testing mysql

4.1. Startup mysql

hkpu10% <home dir>/mysql/support-files/mysql.server start


hkpu10% cd <home dir>/mysql/support-files
hkpu10% ./mysql.server start
Starting MySQL
. SUCCESS!

Created by ITS Page 4 Updated on 9-Sep-2009


hkpu10% ps –ef | grep ittest

ittest 8646 1 0 11:47:38 pts/1 0:00 /bin/sh /rhome2/it/ittest/mysql5/bin/mysqld_safe --


datadir=/rhome2/it/ittest
ittest 8742 8646 0 11:47:39 pts/1 0:20 /rhome2/it/ittest/mysql-5.1.37-solaris10-
sparc/bin/mysqld --defaults-extra-fi

Please refer to Appendix II Q3 of this document if there is error shown


when running above step to start mysql.

4.2. Set password for mysql root user


Assume the root user‟s password is <PASSWORD> and please be
reminded to startup mysql server before setting password. That is to say, you
should be able to run procedure 4.1 successfully, without any error in prior to run
procedure 4.2.

hkpu10% cd <home dir>/mysql/


hkpu10% ./bin/mysqladmin --defaults-file=<home dir>/mysql/data/my.cnf –u root
password „<PASSWORD>‟
hkpu10% ./bin/mysqladmin --defaults-file=<home dir>/mysql/data/my.cnf –h hkpu10 -u
root password „<PASSWORD>‟

4.3. Create a mysql user for testing connectivity:

This example uses a PHP program to make a connection to the mysql


server. The PHP program runs in myweb.polyu.edu.hk while the mysql server
running in hkpu10.polyu.edu.hk. Therefore, you have to create a user for such
mysql connection from the hosts.

Assume that the user is <USER> and password is <PASS> for connecting
myWeb service:

hkpu10% cd <home dir>/mysql


hkpu10% ./bin/mysql --defaults-file=<home dir>/mysql/data/my.cnf -u
root -p
Enter Password:
(please enter the password you have setup in step 3.2)

mysql>use mysql

mysql> insert into user values ('hkpu63', „<USER>‟,


old_password('<PASS>'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y',
'','','','',0,0,0,0);

Created by ITS Page 5 Updated on 9-Sep-2009


mysql> insert into user values ('hkpu63.polyu.edu.hk', „<USER>‟,
old_password('<PASS>'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y',
'','','','',0,0,0,0);

mysql> insert into user values ('hkpu73', „<USER>‟,


old_password('<PASS>'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y',
'','','','',0,0,0,0);

mysql> insert into user values ('hkpu73.polyu.edu.hk', „<USER>‟,


old_password('<PASS>'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y',
'','','','',0,0,0,0);

mysql> select host from user;

(You should be able to see below four rows of hosts with above setting)

for example:
mysql> select host from user;
+-------------------------+
| host |
+-------------------------+
| hkpu63 |
| hkpu63.polyu.edu.hk |
| hkpu73 |
| hkpu73.polyu.edu.hk |
+-------------------------+

mysql> flush privileges;


mysql> quit

4.4. Write a simple php program to check the connectivity between mysql and
myweb.polyu.edu.hk

hkpu10% cd
hkpu10% cd public_html
hkpu10% vi testmysql.php

<?php
$dbname = "mysql";
$host = "hkpu10.polyu.edu.hk:<port num>";
$user = "<USER>";
$pass = "<PASS>";

$dbh = mysql_connect($host, $user, $pass) or die(mysql_error());


mysql_select_db($dbname, $dbh);
echo "Remote Connect Successful";
?>

Created by ITS Page 6 Updated on 9-Sep-2009


Please note that:

$host = server where your mysql is running


$user = <USER> you created in step 4.3 who has been granted access
right to the mysql server running in $host
$pass = <PASS> the password setup for $user in step 4.3

Open Web Browser, type the URL:

http://myweb.polyu.edu.hk/~<NetID>/testmysql.php

If the page return “Remote Connect Successful”, then that means your mysql
installed successfully.

Created by ITS Page 7 Updated on 9-Sep-2009


Appendix I: Useful Command

A.1. mysql startup, shutdown and restart:

mysql Startup
hkpu10% <home dir>/mysql/support-files/mysql.server start
mysql Shutdown:
hkpu10% <home dir>/mysql/support-files/mysql.server stop
mysql Restart
hkpu10% <home dir>/mysql/support-files/mysql.server restart

A.2. Login mysql root user

hkpu10% cd <home dir>/mysql


hkpu10% ./bin/mysql --defaults-file=<home dir>/mysql/data/my.cnf -u
root –p

A.3 Check your mysql process is up running

hkpu10% ps –ef | grep <netid>


hkpu10% ps –ef | grep ittest

ittest 8646 1 0 11:47:38 pts/1 0:00 /bin/sh /rhome2/it/ittest/mysql5/bin/mysqld_safe --


datadir=/rhome2/it/ittest
ittest 8742 8646 0 11:47:39 pts/1 0:20 /rhome2/it/ittest/mysql-5.1.37-solaris10-
sparc/bin/mysqld --defaults-extra-fi
You would see two mysql processes, namely mysqld_safe and mysqld, owned by
your netid are running.

Created by ITS Page 8 Updated on 9-Sep-2009


Appendix II : FAQ

Q1: When I run the “tar” command mentioned in step 1.1, there was an error. What
should I do?

Ans1: Firstly, please check the source file you downloaded from
http://dev.mysql.com/downloads/mysql/5.1.html#solaris is correct:
 filename in .tar format
 version of mysql source should be 5.1.37 or later
 the source is for Solaris 10 (SPARC, 32 bit)

Secondly, please check you have sufficient disk quota for mysql installation. You
should have at least 600 MB free disk space available.

Q2: How to check if I have started mysql server?

Ans2: You may check for any processes that have been started by your <NetID>:
hkpu10% ps –ef | grep <NetID>

Q3: When I start mysql, it said “ERROR”, what should I do?

Ans3: Please check the following one by one:

 The configuration file you have done in step 3.1 and step 3.3. Are the parameters
$datadir and $basedir configured correctly?
 Is the port <port num> free for use? You should NOT choose any port that is in
“LISTEN” state.
 You may examine the mysql log located in <home dir>/mysql/data/. The file
named hkpu10.err collects detailed messages for startup/shutdown of mysql.
While another file called hkpu10.pid saved your mysql process id.
 Please check if you have sufficient disk quota for mysql startup. mySQL will
generate some system files. You would need 600 MB disk space for mysql
version 5.

Q4: I copied the mysql commands from a notepad/MS Word document and paste into the
Unix environment. I read from screen that the command is correctly typed but error
occurs.

Ans4: You are advised not to “copy and paste” Unix commands from non-unix
environment into unix servers. There might be unexpected result if you “copy and paste”
Unix commands from Windows environment (or different OS environment). Please type
the whole command word by word in Unix Server prompt.

Q5: The web browser replied an Error with "Could not connect Host to this mySQL
server", what should I do?

Created by ITS Page 9 Updated on 9-Sep-2009


Ans5: Please grant the access privilege for connecting myWeb service on the new hosts.
Assume that the user is <USER> & password is <PASS> for connecting myWeb service:

hkpu10% cd <home dir>/mysql


hkpu10% ./bin/mysql --defaults-file=<home dir>/mysql/data/my.cnf -u root -p
Enter Password:
(please enter the password you have setup in step 4.2 in mySQL installation and
configuration guide)

mysql> use mysql

mysql> insert into user values ('hkpu63', „<USER>‟, old_password('<PASS>'),


'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y','Y','Y','Y', '','','','',0,0,0,0);

mysql> insert into user values ('hkpu63.polyu.edu.hk', „<USER>‟,


old_password('<PASS>'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y', '','','','',0,0,0,0);

mysql> insert into user values ('hkpu73', „<USER>‟, old_password('<PASS>'),


'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y','Y','Y','Y', '','','','',0,0,0,0);

mysql> insert into user values ('hkpu73.polyu.edu.hk', „<USER>‟,


old_password('<PASS>'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y',
'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y', '','','','',0,0,0,0);

mysql> flush privileges;


mysql> quit

Try again the php program in myWeb.

Created by ITS Page 10 Updated on 9-Sep-2009

You might also like