Friday, August 26, 2011

Downgrade PHP


This post is all about downgrading your PHP 5.3.x to PHP 5.2 because some of your old packages will not work with the PHP 5.3.x.

Essentially, all you have to do is tell the apt system where to find Karmic packages and then tell it that you want it to use Karmic's PHP packages.

So put the "karmic.list" in /etc/apt/sources.list.d and the "php" into /etc/apt/preferences.d.

Then:
sudo apt-get update

sudo apt-get remove php5 libapache2-mod-php5 php5-xsl php5-gd php-pear php5-mysql php5-curl php5-memcache

sudo apt-get install php5 libapache2-mod-php5 php5-xsl php5-gd php-pear php5-mysql php5-curl php5-memcache

If you had not already installed apache, php, and mysql, you can do that with the above files in place and get the right versions without removing anything:

sudo apt-get install apache2 mysql-server php5 libapache2-mod-php5 php5-xsl php5-gd php-pear libapache2-mod-auth-mysql php5-mysql php5-curl php5-memcache

Note: Your php.ini will have been replace, so you have to reset custom settings like memory_limit.

Friday, August 19, 2011

MySql Forgot Password

If you know the password then it is very easy for you to reset the MySql Password but what if you do not remember the password and want to reset it.

To figure it out I spent almost 2 days and now I am sharing so that same thing does not happen with you.

Now, we just need to start MySQL with a flag to tell it to ignore any username/password restrictions which might be in place. Once that is done you can successfully update the stored details.

First of all you will need to ensure that your database is stopped:
root@ravi: /etc/init.d/mysql stop

Now you should start up the database in the background, via the mysqld_safe command:
root@ravi:~# /usr/bin/mysqld_safe --skip-grant-tables &
[1] 6702
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6763]: started
Here you can see the new job (number "1") has started and the server is running with the process ID (PID) of 6702.

Now that the server is running with the --skip-grant-tables flag you can connect to it without a password and complete the job:

root@ravi:~$ mysql --user=root mysql
Enter password:

mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';

Query OK, 2 rows affected (0.04 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.02 sec)

mysql> exit

Bye

Hope this save your time :)

Tuesday, July 12, 2011

Ubuntu 11.04 Login with Root User

I know sometimes it is very easy for any user to do this, but I got something else that took my lots of time to get "root" access.

While using Ubuntu 11.04 I got an unexpected error i.e. "sudo: must be setuid root" and for this I need to login with root user but how as when I tried to login it is giving me the same error.

I read somewhere that for the above problem I need to start my system on Recovery Console, but how? As soon as I start my system it is taking me to GUI Login Screen.

Now to get access of "root" user follow the below steps:
1) Restart system by HOLDING SHIFT key.
2) While restarting press ESC key till you get the OS menu telling you for the recovery mode (Do not release the SHIFT key)
3) Now you are on ROOT user and do whatever you want.

Hope this helps :)

Sudo: must be setuid root

Here is a solution to a common error when using sudo

Open terminal (CTRL+ALT+T) and use below commands

loginuser> sudo -l
sudo: must be setuid root
loginuser>

To fix the error above chown and chmod the sudo file as root, in my case the file is in /usr/bin

root>chown root:root /usr/bin/sudo
root>chmod 4755 /usr/bin/sudo
root>chmod 0400 /etc/sudoers
reboot system

That should fix the error and you should be able to sudo without a problem.

Note: You must be login with "root" user.

Friday, July 8, 2011

Install PHPUnit

Install pear on windows
You probably need to do a very simple thing.
C:\>xampp\php\go-pear.bat
if not upgraded then use "pear upgrade-all"

Install pear on Ubuntu
Install: sudo apt-get install php-pear
update its own channel: sudo pear channel-update pear.php.net
upgrade: sudo pear upgrade-all

Now proceed with below steps
  1. pear channel-discover pear.phpunit.de
  2. pear channel-discover pear.symfony-project.com
  3. pear install phpunit/PHPUnit