Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Tuesday, August 18, 2009

3 Steps To Turn-On Desktop Cube

In Ubuntu, by default, you cannot see the beauty of compiz desktop cube and desktop rotation. You must turn it on manually. Here are 3 steps to do it:
  1. Open Terminal and type: sudo apt-get install compizconfig-settings-managerThis is the GUI tool to easily manage the compiz configuration.
  2. Go to System->Preferences->CompizConfig Settings Manager. On the left panel, click General. On the right, click General Options. Go to Desktop Size tab and set Horizontal Virtual Size to 4 then click Back button on left panel.
  3. Now click Desktop on left panel. On the right, tick off Desktop Cube and Rotate Cube to enable them. Later, if you want to change the appearance of your cube, just enter the Desktop Cube menu. While if you want to change the rotation setting, enter the Rotate Cube menu.
Now you can try it. Push Ctrl+Alt buttons together then left-click any area on the screen and move your mouse. Wow...look at that. Cool hah?

But wait...if your desktop form is not a cube (cylinder or sphere) or if you want to change the form (or effects), follow these steps:
  1. On the left panel, click Effects. On the right, tick off and click Cube Reflection and Deformation.
  2. In Cube caps tab, you can change the appearance of top and bottom side of the cube.
  3. In Reflection tab, you can manage the background reflection while the cube is rotating
  4. And in Deformation tab, you can change the form of the cube to sphere or cylinder.
Don't forget to leave a comment so I know that this post is useful to you.
Read more...

Sunday, August 16, 2009

MySQL Backup and Restore Using PHP

It is very important to make regular backup of your important data to keep them from data loss. There are several ways to backup and restore your MySQL database. The easiest way is by copying the database directory in:
/var/lib/mysql
or
C:\xampp\mysql\data (or MySQL installation folder if you are not using Xampp)
But you cannot do this if your database table is using InnoDB engine. Your InnoDB table will not be recognized when it is restored in another MySQL server. So I don’t recommend this way to backup your MySQL database. This tutorial will show you how to backup and restore your database safely.

Backup Databases


There are at least three ways to backup your MySQL Database:
  1. Use phpMyAdmin to do the backup.
  2. Run mysqldump from command line or using php system() function.
  3. Execute a database backup query from PHP file.
If you want to backup your database from your application (PHP), you can do ways 2 or 3. I prefer to backup with mysqldump and I use this in all of my project.
The format of mysqldump command is like this:
$ mysqldump --opt -u [uname] -p[pass] [dbname] > [backupfile.sql]
or
C:\xampp\mysql\bin\mysqldump.exe --opt -u [uname] -p[pass] [dbname] > [backupfile.sql]
  • [uname] Your database username
  • [pass] The password for your database (Note: there is no space between -p and the password)
  • [dbname] The name of your database
  • [backupfile.sql] The filename for your database backup
  • [--opt] The mysqldump option
For example, to backup a database named 'Tutorial' with the username ‘root’ and password ‘toor’ to a file tutor_backup.sql, you should accomplish this command:
$ mysqldump -u root -ptoor Tutorial > tutor_backup.sql
This command will backup the 'Tutorial' database into a file called tutor_backup.sql which will contain all the SQL statements needed to re-create the database.

Backup Certain Tables

With mysqldump command you can specify certain tables of your database you want to backup. For example, to back up only php_tutorials and asp_tutorials tables from the 'Tutorial' database accomplish the command below. Each table name has to be separated by space.
$ mysqldump -u root -ptoor Tutorial php_tutorials asp_tutorials > tutor_backup.sql

Backup Certain Databases

Sometimes it is necessary to back up more than one database at once. In this case you can use the --database option followed by the list of databases you would like to backup. Each database name has to be separated by space.
$ mysqldump -u root -ptoor --databases Tutorial Articles Comments > t_a_c_backup.sql

Backup All Database

If you want to back up all the databases in the server at one time you should use the --all-databases option. It tells MySQL to dump all the databases it has in storage.
$ mysqldump -u root -ptoor --all-databases > alldb_backup.sql

The mysqldump command has also some other useful options:
--add-drop-table: Tells MySQL to add a DROP TABLE statement before each CREATE TABLE in the dump.
--no-data: Dumps only the database structure, not the contents.
--add-locks: Adds the LOCK TABLES and UNLOCK TABLES statements you can see in the dump file.


Restore Databases


Above we backup the Tutorial database into tut_backup.sql file. To re-create the Tutorial database you should follow two steps:
Create an appropriately named database on the target machine
Load the file using the MySQL command:
$ mysql -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]
or
C:\xampp\mysql\bin\mysql.exe -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]

Have a look how you can restore your tutor_backup.sql file to the Tutorial database.
$ mysql -u root -ptoor Tutorial < tutor_backup.sql

If you need to restore a database that already exists, you'll need to use mysqlimport command. The syntax for mysqlimport is as follows:
$ mysqlimport -u [uname] -p[pass] [dbname] [backupfile.sql]

Here are my scripts to backup and restore MySQL database through PHP.With this backup script, the output file can be downloaded. Just load the script from browser and save the output file. The output file is compressed in ZIP format.
The restore script gets the file through upload form. Just browse the output file that has been downloaded with backup script and click Upload button.

Please post below if you get a problem applying this tutorial.
Read more...

Saturday, August 15, 2009

Compiz Error After Setting Desktop Effect To None

May be this is one of many reasons why people still thinking that Linux is wearying OS. For example, when you are playing with the system settings or your desktop preferences, your system suddenly stop working and you don’t know what the hell is going on. Then you are shocked and thinking hard what you have to do to make your system works again.

But it doesn’t matter if you have a big curiosity in Linux. Just open firefox or the other browsers and start to search the solutions of your problems like what I will explain in this post.

It was an accident when I click None option in desktop effect setting. I thought it’s not a problem coz I could reset the setting back to Extra option. So I reset the option. But I was wrong, suddenly I got the message telling me that compiz-daemon couldn’t be started. Oh sh*t…what’s the going on?

After searching for the solutions by using many keywords, I got a nice script to detect compiz problems. The script name was compiz-check. This script doesn’t only detect compiz problems but it can also repair the problems. So if you get this problem just download compiz-check and run in your terminal.

Before you run compiz-check, change the permission to make it executable:
$ chmod 744 compiz-check
$ ./compiz-check



Don't forget to leave a comment so I know that this post is useful to you.
Read more...