Install Oracle database support in PHP CentOS 6

Howto install Oracle database support in PHP for CentOS 6 and Amazon Linux AMI.

To access an Oracle database from PHP you need to use the OCI8 extension. I will take you through the quick process of getting it up and running.

This guide assumes you already have Apache and PHP installed in your environment running on either CentOS 6 or Amazon Linux AMI. It also assumes the Oracle database you wish to connect to is on a remote host.

Continue reading…

Python MySQL Backup Script

Here is a simple python based MySQL backup script. It will individually dump all your MySQL databases and then tar gzip them to a specified location.

Having Python installed is the only real prerequisite.

Script Details

Note, that the script isn’t verbose unless there is an error. This is so you can schedule it as a cron job, and only get an email when something goes wrong.

It also uses a configuration file as a security precaution. The reason for using a config file, it prevents the user and password being visible in the running processes list. So for example if you were running a mysqldump and put password into your command line, another user could query the running processes and see the password.

I typically store my scripts in the /usr/local/bin directory of my Linux systems. In general, it’s a good place to store custom scripts and applications.

You’ll also need to create your configuration file, like below:

In my case, I store the config file as /etc/mysql.cnf however make sure that it’s only readable by the root user.

Continue reading…

Solution – Oracle 11g Password Expiry ORA-28002

ERROR: ORA-28002: the password will expire within 6 days. Lets see what we can do about resolving this issue.

You could simply just change the users password. In an ideal and secure world, this is exactly what you would do. Though this may not be practical, there may be a whole host of reasons for postponing the change.

In Oracle 11g, users are assigned to a profile, the default profile is named “DEFAULT”. This default profile comes configured with a maximum password lifetime of a 180 days.

[box type="info"] Just note that this document’s steps have been performed on Oracle 11g Release 11.2.0.3.0 running on Red Hat Enterprise Linux 6.3. The SQL syntax provided “should” work on all Oracle 11g platforms.[/box]

Step 1: Identify the Users Profile

Log into Oracle 11g using SQL*Plus tool as sysdba

Lets confirm that the user is running the default profile. Note you must capitalize the username.

As you can see, the user has the profile of “DEFAULT” configured.

Step 2: View the Profile settings

Lets examine the settings of the profile

As you can see the PASSWORD_LIFE_TIME is to 180 days, you may configure this however you want.

Step 3: Set PASSWORD_LIFE_TIME

In this example, we’re going to make the password life unlimited so that it never expires. This may not be the wisest thing to do in a production environment. However there may be circumstances that require a password change at a later date.

To make this change we simply need to run the following command:

Step 4: Re-Enter the Password

You may notice that even after setting the password expiry to unlimited you are still getting the “ERROR: ORA-28002: the password will expire” message. I’m guessing this is due to additional processes that Oracle does in the background for checking password age etc. So this forces us to “reset” the password to it’s current value to remove the error.

This is done via the following SQL

Just note that the password must be double quoted and not single quoted.

…and that’s it, you should no longer receive the “ORA-28002: the password will expire” message for USER1 when logging in.

[box type="warning"] Just note that having never expiring passwords probably isn’t the best password policy to maintain. Oracle’s password expiration setting is a great way to remind users and admin’s to change their passwords regularly.[/box]

[author] [author_image timthumb='on']http://mcdee.com.au/wp-content/uploads/2012/11/photo.jpg[/author_image] [author_info]Andrew McDonald is an IT Systems Admin and all round technology junkie. Absolutely a jack-of-all-trades and not one to shy away from a challenge.


 [/author_info] [/author]