Archive for June, 2009

SBDavid

Pgsql query failed

Pgsql query failed

If you are getting the error as follows.

Warning: pg_query() [function.pg-query]: Query failed: ERROR: permission denied for relation cg_ref_codes in /home/user/public_html/xxx.php on line 48
Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL result resource in /home/user/public_html/xxxx.php on line 50

Resolution

1. Open the pgsql configuration file.

vi /var/lib/pgsql/data/pg_hba.conf
local all all md5
host all all 127.0.0.1 255.255.255.255 md5

The file need to change as follows
local all all md5
host all all 127.0.0.1 255.255.255.255 password

2. Save the file and restart pgsql.

/etc/init.d/postgresql stop
/etc/init.d/postgresql start

How to add a user to PostgreSQL database

Following are the steps to add a user ‘testuser ‘ to the PostgreSQL database ‘testdb’ and grant access to that database;

First you need to make sure that the user is already existing in the server.

# grep testuser /etc/passwd

Else you need to create a user by type the following commands:

# adduser testuser
# passwd testuser
su - postgres
/usr/local/pgsql/bin/psql template1
/usr/local/pgsql/bin/psql -d template1 -U postgres (This command will result into the PostgreSQL command prompt)

Welcome to psql , the PostgreSQL interactive terminal.

template1=#

Now you need to add the user ‘testuser’ and give access to the database named ‘testdb’.

Follow the steps given below:

template1=# CREATE USER tom WITH PASSWORD ‘testPassword’;
template1=# CREATE DATABASE testdb;
template1=# GRANT ALL PRIVILEGES ON DATABASE testdb to testuser;

then quit from the template1 prompt:

Now you need to login as user ‘testuser’;

@ ~]$ su - testuser
Password:
[testuser@ ~]$ /usr/local/pgsql/bin/psql -d testdb -U testuser
Welcome to psql, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

testdb=>

Warning message in PhpMyAdmin after upgrading MySQL version to 5 In cPanel server.

In cPanel server after upgrading MySQL version to 5, PhpMyAdmin shows a warning message as given below

Your PHP MySQL library version 4.1.22 differs from your MySQL server version 5.0.45

CPanel’s internal PHP is not compiled with MySQL 5. That is why you are facing this issue. In order to fix this, perform the following steps.

1) Run the script /scripts/makecpphp
2) Copy the PHP binary inside /var/cpanel/3rdparty//bin/ to /usr/local/cpanel/3rdparty/bin/

That will fix the problem.

SBDavid

MySQL Socket Error in phpMyAdmin

MySQL Socket Error in phpMyAdmin

While accessing phpMyAdmin, you may get the following error.

#2002 - The server is not responding (or the local MySQL server’s socket is not correctly configured)

This is due to the missing socket file in the location /tmp.

The socket path which is specified in the phpMyAdmin configuration file is /tmp/mysql.sock.

$ vi /usr/local/cpanel/base/3rdparty/phpMyAdmin/config.inc.php
cfg['Server']['socket'] = ‘/tmp/mysql.sock’;

If mysql.sock is missing in /tmp, then create a link to the mysql.sock file in /var/lib/mysql.

$ ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

There is also another fix for this issue.

1. Open the phpMyadmin config file “config.inc.php”.

vi /usr/local/cpanel/base/3rdparty/phpMyAdmin/config.inc.php

2.Locate the line:

$cfg['Servers'][$i]['host'] = ‘localhost’;

3.Replace ‘localhost’ with ‘127.0.0.1′ and save.

$cfg['Servers'][$i]['host'] = ‘127.0.0.1′;

MySQL: got error 28 from server handler

This error means no space left on hard disk. If you get his error, you need to check all filesystems where MySQL operates.

a) Stop mysql server

# /etc/init.d/mysql stop
OR
# /etc/init.d/mysqld stop

b) Check filesystem and /tmp directories:

$ df -h
$ cd /tmp
$ df -h /tmp

c) Remove files from /tmp to free up space:

# cd /tmp
# rm -rf *

d) Look into /var/log directory and remove or compress logs file.

e) Use myisamchk command to check and repair of ISAM table:

# cd /var/lib/mysql
# myisamchk

f) Increase disk space (add new hard disk or remove unwanted softwares)

g) Start the mysql server:

# /etc/init.d/mysql start
OR
# /etc/init.d/mysqld start

« Prev - Next »