Skip to content

Instantly share code, notes, and snippets.

@chicks
Last active October 13, 2015 15:48
Show Gist options
  • Save chicks/4219413 to your computer and use it in GitHub Desktop.
Save chicks/4219413 to your computer and use it in GitHub Desktop.
SugarCRM on DB2
<?php
// Use this to test connectivity to db2. Useful for checking IIS permissions
$database = 'DATABASE=SUGARCRM;HOSTNAME=localhost;PORT=50000;PROTOCOL=TCPIP;UID=db2admin;PWD=Sugar123!;';
$conn = db2_connect($database, '', '');
if ($conn) {
echo "Connection succeeded.";
db2_close($conn);
}
else {
$stmt_err = db2_stmt_error();
$stmt_err_msg = db2_stmt_errormsg();
$conn_err = db2_conn_error();
$conn_err_msg = db2_conn_errormsg();
echo "Connection failed.";
echo "Statement Error : $stmt_err Statement Error Message : $stmt_err_msg";
echo "Connection Error : $conn_err Connection Error Message : $conn_err_msg";
}
?>
# NOTE this creates a default 32k table space which is the maximum. Only a few tables in Sugar need 8k, others need only 4k
# However if you are using Studio the table needs enough extra space to add columns
# Also note that the specified collation is case insensitive US. By default DB2 is case sensitive.
db2 "CREATE DATABASE SUGARCRM USING CODESET UTF-8 TERRITORY US COLLATE USING UCA500R1_LEN_S2 PAGESIZE 32 K"
# Ensure the SYSTOOLS table space is created
db2 "connect to SUGARCRM"
db2 "CALL GET_DBSIZE_INFO(?, ?, ?, -1)"
#
# Confirm you have SYSADM Privileges
#
# View current user
db2 "VALUES SYSPROC.AUTH_GET_INSTANCE_AUTHID()"
# View current user's authorities (Replace DB2ADMIN with the result of the previous command)
db2 "SELECT * FROM TABLE (SYSPROC.AUTH_LIST_AUTHORITIES_FOR_AUTHID ('DB2ADMIN', 'U'))AS T ORDER BY AUTHORITY"
# Grant DBADM to user
db2 "GRANT DBADM ON DATABASE TO USER DB2ADMIN"
# Sugar 6.4 and 6.5 need the Full Text Search engine up and running and operational.
# Currently only KBDocuments uses full text search by default in Sugar but other FTS indexes can be created.
# Enable FTS
db2ts "enable database for text connect to SUGARCRM"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment