Tuesday, 25 September 2012

Linux Real Time Issues-5

File system check failed. Won't boot.


Here, try this one.

Bootup from Live CD, than go to terminal and:

sudo blkid

it will return something like:

/dev/sda5: UUID="eae4ddca-b9b1-48d4-abba-e26bc44027a4" TYPE="ext4"
/dev/sda6: UUID="7ff08df9-693a-4841-a459-b934c672a821" TYPE="swap"

(This is mine result, sda5 is my ubuntu partition).

Ok

copy its UUID

Than open on your filesystem file /etc/fstab

Search for your sda and paste UUID there. (replace wrong UUID number)


---------------------------------------------------------------------------------------
root file system check failed

Been having a few issues. Basically I'm locked of my laptop.

It says: Root filesystem check failed
A maintenance shell will now be started
CONTROL-D will terminate this shell and reboot the system
root@charley-laptop:~# 



It looks like you need to run fsck on your root partition. You can do this from a live CD (make sure the partition is not mounted) or you can do it from the maintenance shell if you remount the root partition read only.

In either case just make sure the root partition is not mounted read/write.

Code:
fsck /dev/sdX
where X is the partition for /. You can do a trail run with the -N switch.



It 'n' to not ignore the error.

Run fsck again but try using a backup superblock instead of the main one. That one may be corrupted.

Run the trail run with the -N switch to see what it says.


---------------------------------------------------------------------------------------------
So you using GDM. It sounds like it may be corrupted. What happens if you drop to a virtual terminal (ctrl + alt + f1) and restart GDM ?

Code:
sudo service gdm restart
or
Code:
sudo /etc/init.d/gdm restart

------------------------------------------------------------------------------------------------------
When I boot at this moment I get the following message during the boot,
when the file system of sda4 (the new installation) is being checked.

================================================== =========================

* Checking file systems...
1176

fsck 1.40.8 (13-mar-2008)
fsck.ext3: Unable to resolve 'UUID=88202516-902e-4382-9291-680daed83138'
fsck died with exit status 8
[fail]
* File system check failed.
A log is being saved in /var/log/fsck/checkfs
if that location is writable.
please repair the file system manually.

* A maintenance shell will now be started.

CONTROL-D will terminate this shell and resume system boot.

bash: no job control in this shell
bash: groups: command not found
bash: lesspipe: command not found
bash: command: command not found
bash: the: command not found
bash: dircolors: command not found
bash: command: command not found
bash: the: command not found
root@ultraros-desktop:~#

================================================== ========================

When I press "CONTROL-D" or "Exit" or "Reboot" the system boots up

and I can use her, but I prefer to solve this so I can boot the normal way.

he log file (/var/log/fsck/checkfs) contains

================================================== ===========================

Log of fsck -C3 -R -A -a
Mon Sep 8 15:18:30 2008

fsck 1.40.8 (13-Mar-200
fsck.ext3: Unable to resolve 'UUID=88202516-902e-4382-9291-680daed83138'

fsck died with exit status 8

Mon Sep 8 15:18:30 2008
----------------
Code:
cat /etc/fstab
Code:
joop@UltraRos-desktop:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
# /dev/hda4
UUID=620f6373-ceb4-43d2-a5d8-1f58338de857 /               ext3    defaults,errors=remount-ro 0       1
# /dev/hda3
UUID=88202516-902e-4382-9291-680daed83138 /media/hda3     ext3    defaults        0       2
# /dev/hda5
UUID=76D0374CD037123B /media/hda5     ntfs    defaults,umask=007,gid=46 0       1
# /dev/hda6
UUID=13DFA768E0039D61 /media/hda6     ntfs    defaults,umask=007,gid=46 0       1
# /dev/hda1
UUID=22de6324-6467-428b-9d2f-4074c5f39b8c none            swap    sw              0       0
# /dev/hda7
UUID=ed74fe7a-4758-4fbf-a753-0b2416d064c4 none            swap    sw              0       0
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto,exec 0       0
/dev/hdd        /media/cdrom1   udf,iso9660 user,noauto,exec 0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,exec 0       0
joop@UltraRos-desktop:~$
================================================== ===========================

I hope this will help to find a solution.

ok, this line "# /dev/hda3
UUID=88202516-902e-4382-9291-680daed83138 /media/hda3 ext3 defaults 0 2" has the possibly bad uuid entry, please post the output of this command

Code:
sudo vol_id --uuid /dev/hda3

Monday, 24 September 2012

MySql Bascis

Resetting a forgotten MySQL root password


root@steve:~# /etc/init.d/mysqd stop

root@steve:~# /usr/bin/mysqld_safe --skip-grant-tables &
[1] 6702
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6763]: started

root@steve:~$ 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


root@steve:~# /etc/init.d/mysql start
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..




$ mysqladmin -u root password NEWPASSWORD


$ mysqladmin -u root -p'oldpassword' password newpass


$ mysqladmin -u root -p'abc' password '123456'

$ mysqladmin -u vivek -p oldpassword password newpass


MySql Commands:

Logging In

$ mysql -u <username> -p
Enter password:

Create database

mysql> CREATE DATABASE <database>; 

mysql> CREATE DATABASE vworks; 

We can now check for the presence of this database by typing:
mysql> SHOW DATABASES;
+-----------+
| Database  |
+-----------+
| mysql     |
| vworks    |
+-----------+
2 rows in set (0.06 sec)
Deleting or DROPing a database
DROP DATABASE <database>

Granting Privileges on the new database

GRANT <privileges> 
ON <database> 
TO <user> 
[IDENTIFIED BY <password>] 
[WITH GRANT OPTION]
mysql> GRANT ALL PRIVILEGES 
    -> ON vworks.* 
    -> TO newuser@localhost 
    -> IDENTIFIED BY 'newpassword';  

Revoking privileges




mysql> REVOKE ALL PRIVILEGES 
    -> ON vworks.* 
    -> FROM badvworks@localhost;  

mysqlhotcopy


 mysqlhotcopy -u <username> -p <database> /backup/location/


mysqldump

 mysqldump -u <username> -p <database> [<table>] > file.sql


 mysqldump -u admin -p vworks > vworks.sql


Restoring a Dump

$ mysql -u admin -p vworks < vworks.sql

$ mysql -u admin -p vworks < artist.sql

$ mysql -u admin -p < vworksDB.sql


Optimising a dump

$ mysqldump -u admin -p --opt vworks > vworks.sql

$ mysqldump -u admin -p --databases vworks | \
> mysql -u backup -p MyPassword -h remote.server.com 



mysql> CREATE DATABASE vworks2; 


Remote Client Connection


$ mysql -u <username> -p -h <host>


For example to connect to a fictional vworks.keithjbrown.co.uk server:
$ mysql -u admin -p -h vworks.keithjbrown.co.uk

Non-Interactive Commands


$ mysql -u admin -p vworks -e 'SELECT cds.artist, cds.title FROM cds'

Enter password: 
+------------+------------------------------+
| artist     | title                        |
+------------+------------------------------+
| Jamiroquai | A Funk Odyssey               |
| Various    | Now 49                       |
| westlife   | westlife                     |
| Various    | Eurovision Song contest 2001 |
| Abba       | Abbas Greatest Hits          |




1. How to change the MySQL root user password?

# mysqladmin -u root -ptmppassword password 'newpassword'

# mysql -u root -pnewpassword

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.25-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

2. How to check whether MySQL Server is up and running?

# mysqladmin -u root -p ping
Enter password:
mysqld is alive

3. How do I find out what version of MySQL I am running?

Apart from giving the ‘Server version’, this command also displays the current status of the mysql server.


# mysqladmin -u root -ptmppassword version

mysqladmin  Ver 8.42 Distrib 5.1.25-rc, for redhat-linux-gnu on i686
Copyright (C) 2000-2006 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version          5.1.25-rc-community
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/lib/mysql/mysql.sock
Uptime:                 107 days 6 hours 11 min 44 sec

Threads: 1  Questions: 231976  Slow queries: 0  Opens: 17067
Flush tables: 1  Open tables: 64  Queries per second avg: 0.25

4. What is the current status of MySQL server?

# mysqladmin -u root -ptmppassword status

Uptime: 9267148
Threads: 1  Questions: 231977  Slow queries: 0  Opens: 17067
Flush tables: 1  Open tables: 64  Queries per second avg: 0.25
The status command displays the following information:
  • Uptime: Uptime of the mysql server in seconds
  • Threads: Total number of clients connected to the server.
  • Questions: Total number of queries the server has executed since the startup.
  • Slow queries: Total number of queries whose execution time waas more than long_query_time variable’s value.
  • Opens: Total number of tables opened by the server.
  • Flush tables: How many times the tables were flushed.
  • Open tables: Total number of open tables in the database.

5. How to view all the MySQL Server status variable and it’s current value?

# mysqladmin -u root -ptmppassword extended-status
+-----------------------------------+-----------+
| Variable_name                     | Value     |
+-----------------------------------+-----------+
| Aborted_clients                   | 579       |
| Aborted_connects                  | 8         |
| Binlog_cache_disk_use             | 0         |
| Binlog_cache_use                  | 0         |
| Bytes_received                    | 41387238  |
| Bytes_sent                        | 308401407 |
| Com_admin_commands                | 3524      |
| Com_assign_to_keycache            | 0         |
| Com_alter_db                      | 0         |
| Com_alter_db_upgrade              | 0         |

6. How to display all MySQL server system variables and the values?

# mysqladmin  -u root -ptmppassword variables
+---------------------------------+---------------------------------+
| Variable_name                   | Value                           |
+---------------------------------+---------------------------------+
| auto_increment_increment        | 1                               |
| basedir                         | /                               |
| big_tables                      | OFF                             |
| binlog_format                   | MIXED                           |
| bulk_insert_buffer_size         | 8388608                         |
| character_set_client            | latin1                          |
| character_set_database          | latin1                          |
| character_set_filesystem        | binary                          |

skip.....

| time_format                     | %H:%i:%s                        |
| time_zone                       | SYSTEM                          |
| timed_mutexes                   | OFF                             |
| tmpdir                          | /tmp                            |
| tx_isolation                    | REPEATABLE-READ                 |
| unique_checks                   | ON                              |
| updatable_views_with_limit      | YES                             |
| version                         | 5.1.25-rc-community             |
| version_comment                 | MySQL Community Server (GPL)    |
| version_compile_machine         | i686                            |
| version_compile_os              | redhat-linux-gnu                |
| wait_timeout                    | 28800                           |
+---------------------------------+---------------------------------+

7. How to display all the running process/queries in the mysql database?

# mysqladmin -u root -ptmppassword processlist
+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host      | db | Command | Time | State | Info             |
+----+------+-----------+----+---------+------+-------+------------------+
| 20 | root | localhost |    | Sleep   | 36   |       |                  |
| 23 | root | localhost |    | Query   | 0    |       | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+
You can use this command effectively to debug any performance issue and identify the query that is causing problems, by running the command automatically every 1 second as shown below.
# mysqladmin -u root -ptmppassword -i 1 processlist
+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host      | db | Command | Time | State | Info             |
+----+------+-----------+----+---------+------+-------+------------------+
| 20 | root | localhost |    | Sleep   | 36   |       |                  |
| 23 | root | localhost |    | Query   | 0    |       | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+

+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host      | db | Command | Time | State | Info             |
+----+------+-----------+----+---------+------+-------+------------------+
| 24 | root | localhost |    | Query   | 0    |       | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+

8. How to create a MySQL Database?

# mysqladmin -u root -ptmppassword create testdb

# mysql -u root -ptmppassword

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 705
Server version: 5.1.25-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| sugarcrm           |
| testdb             |
+--------------------+
4 rows in set (0.00 sec)


Note: To display all tables in a database, total number of columns, row, column types, indexes etc., use the mysqlshow command that we discussed in our previous articles.

9. How to Delete/Drop an existing MySQL database?

# mysqladmin -u root -ptmppassword drop testdb

Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.

Do you really want to drop the 'testdb' database [y/N] y
Database "testdb" dropped

# mysql -u root -ptmppassword

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 707
Server version: 5.1.25-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| sugarcrm           |
+--------------------+
3 rows in set (0.00 sec)

1. How to change the MySQL root user password?

# mysqladmin -u root -ptmppassword password 'newpassword'

# mysql -u root -pnewpassword
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.25-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

2. How to check whether MySQL Server is up and running?

# mysqladmin -u root -p ping
Enter password:
mysqld is alive

3. How do I find out what version of MySQL I am running?

Apart from giving the ‘Server version’, this command also displays the current status of the mysql server.


# mysqladmin -u root -ptmppassword version

mysqladmin  Ver 8.42 Distrib 5.1.25-rc, for redhat-linux-gnu on i686
Copyright (C) 2000-2006 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version          5.1.25-rc-community
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/lib/mysql/mysql.sock
Uptime:                 107 days 6 hours 11 min 44 sec

Threads: 1  Questions: 231976  Slow queries: 0  Opens: 17067
Flush tables: 1  Open tables: 64  Queries per second avg: 0.25

4. What is the current status of MySQL server?

# mysqladmin -u root -ptmppassword status
Uptime: 9267148
Threads: 1  Questions: 231977  Slow queries: 0  Opens: 17067
Flush tables: 1  Open tables: 64  Queries per second avg: 0.25
The status command displays the following information:
  • Uptime: Uptime of the mysql server in seconds
  • Threads: Total number of clients connected to the server.
  • Questions: Total number of queries the server has executed since the startup.
  • Slow queries: Total number of queries whose execution time waas more than long_query_time variable’s value.
  • Opens: Total number of tables opened by the server.
  • Flush tables: How many times the tables were flushed.
  • Open tables: Total number of open tables in the database.

5. How to view all the MySQL Server status variable and it’s current value?

# mysqladmin -u root -ptmppassword extended-status
+-----------------------------------+-----------+
| Variable_name                     | Value     |
+-----------------------------------+-----------+
| Aborted_clients                   | 579       |
| Aborted_connects                  | 8         |
| Binlog_cache_disk_use             | 0         |
| Binlog_cache_use                  | 0         |
| Bytes_received                    | 41387238  |
| Bytes_sent                        | 308401407 |
| Com_admin_commands                | 3524      |
| Com_assign_to_keycache            | 0         |
| Com_alter_db                      | 0         |
| Com_alter_db_upgrade              | 0         |

6. How to display all MySQL server system variables and the values?

# mysqladmin  -u root -ptmppassword variables
+---------------------------------+---------------------------------+
| Variable_name                   | Value                           |
+---------------------------------+---------------------------------+
| auto_increment_increment        | 1                               |
| basedir                         | /                               |
| big_tables                      | OFF                             |
| binlog_format                   | MIXED                           |
| bulk_insert_buffer_size         | 8388608                         |
| character_set_client            | latin1                          |
| character_set_database          | latin1                          |
| character_set_filesystem        | binary                          |

skip.....

| time_format                     | %H:%i:%s                        |
| time_zone                       | SYSTEM                          |
| timed_mutexes                   | OFF                             |
| tmpdir                          | /tmp                            |
| tx_isolation                    | REPEATABLE-READ                 |
| unique_checks                   | ON                              |
| updatable_views_with_limit      | YES                             |
| version                         | 5.1.25-rc-community             |
| version_comment                 | MySQL Community Server (GPL)    |
| version_compile_machine         | i686                            |
| version_compile_os              | redhat-linux-gnu                |
| wait_timeout                    | 28800                           |
+---------------------------------+---------------------------------+

7. How to display all the running process/queries in the mysql database?

# mysqladmin -u root -ptmppassword processlist
+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host      | db | Command | Time | State | Info             |
+----+------+-----------+----+---------+------+-------+------------------+
| 20 | root | localhost |    | Sleep   | 36   |       |                  |
| 23 | root | localhost |    | Query   | 0    |       | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+
You can use this command effectively to debug any performance issue and identify the query that is causing problems, by running the command automatically every 1 second as shown below.
# mysqladmin -u root -ptmppassword -i 1 processlist
+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host      | db | Command | Time | State | Info             |
+----+------+-----------+----+---------+------+-------+------------------+
| 20 | root | localhost |    | Sleep   | 36   |       |                  |
| 23 | root | localhost |    | Query   | 0    |       | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+

+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host      | db | Command | Time | State | Info             |
+----+------+-----------+----+---------+------+-------+------------------+
| 24 | root | localhost |    | Query   | 0    |       | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+

8. How to create a MySQL Database?

# mysqladmin -u root -ptmppassword create testdb

# mysql -u root -ptmppassword
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 705
Server version: 5.1.25-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| sugarcrm           |
| testdb             |
+--------------------+
4 rows in set (0.00 sec)


Note: To display all tables in a database, total number of columns, row, column types, indexes etc., use the mysqlshow command that we discussed in our previous articles.

9. How to Delete/Drop an existing MySQL database?

# mysqladmin -u root -ptmppassword drop testdb
Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.

Do you really want to drop the 'testdb' database [y/N] y
Database "testdb" dropped

# mysql -u root -ptmppassword
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 707
Server version: 5.1.25-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| sugarcrm           |
+--------------------+
3 rows in set (0.00 sec)

1. How to change the MySQL root user password?

# mysqladmin -u root -ptmppassword password 'newpassword'

# mysql -u root -pnewpassword
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.1.25-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

2. How to check whether MySQL Server is up and running?

# mysqladmin -u root -p ping
Enter password:
mysqld is alive

3. How do I find out what version of MySQL I am running?

Apart from giving the ‘Server version’, this command also displays the current status of the mysql server.
# mysqladmin -u root -ptmppassword version
mysqladmin  Ver 8.42 Distrib 5.1.25-rc, for redhat-linux-gnu on i686
Copyright (C) 2000-2006 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version          5.1.25-rc-community
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/lib/mysql/mysql.sock
Uptime:                 107 days 6 hours 11 min 44 sec

Threads: 1  Questions: 231976  Slow queries: 0  Opens: 17067
Flush tables: 1  Open tables: 64  Queries per second avg: 0.25

4. What is the current status of MySQL server?

# mysqladmin -u root -ptmppassword status
Uptime: 9267148
Threads: 1  Questions: 231977  Slow queries: 0  Opens: 17067
Flush tables: 1  Open tables: 64  Queries per second avg: 0.25
The status command displays the following information:
  • Uptime: Uptime of the mysql server in seconds
  • Threads: Total number of clients connected to the server.
  • Questions: Total number of queries the server has executed since the startup.
  • Slow queries: Total number of queries whose execution time waas more than long_query_time variable’s value.
  • Opens: Total number of tables opened by the server.
  • Flush tables: How many times the tables were flushed.
  • Open tables: Total number of open tables in the database.

5. How to view all the MySQL Server status variable and it’s current value?

# mysqladmin -u root -ptmppassword extended-status
+-----------------------------------+-----------+
| Variable_name                     | Value     |
+-----------------------------------+-----------+
| Aborted_clients                   | 579       |
| Aborted_connects                  | 8         |
| Binlog_cache_disk_use             | 0         |
| Binlog_cache_use                  | 0         |
| Bytes_received                    | 41387238  |
| Bytes_sent                        | 308401407 |
| Com_admin_commands                | 3524      |
| Com_assign_to_keycache            | 0         |
| Com_alter_db                      | 0         |
| Com_alter_db_upgrade              | 0         |

6. How to display all MySQL server system variables and the values?

# mysqladmin  -u root -ptmppassword variables
+---------------------------------+---------------------------------+
| Variable_name                   | Value                           |
+---------------------------------+---------------------------------+
| auto_increment_increment        | 1                               |
| basedir                         | /                               |
| big_tables                      | OFF                             |
| binlog_format                   | MIXED                           |
| bulk_insert_buffer_size         | 8388608                         |
| character_set_client            | latin1                          |
| character_set_database          | latin1                          |
| character_set_filesystem        | binary                          |

skip.....

| time_format                     | %H:%i:%s                        |
| time_zone                       | SYSTEM                          |
| timed_mutexes                   | OFF                             |
| tmpdir                          | /tmp                            |
| tx_isolation                    | REPEATABLE-READ                 |
| unique_checks                   | ON                              |
| updatable_views_with_limit      | YES                             |
| version                         | 5.1.25-rc-community             |
| version_comment                 | MySQL Community Server (GPL)    |
| version_compile_machine         | i686                            |
| version_compile_os              | redhat-linux-gnu                |
| wait_timeout                    | 28800                           |
+---------------------------------+---------------------------------+

7. How to display all the running process/queries in the mysql database?

# mysqladmin -u root -ptmppassword processlist
+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host      | db | Command | Time | State | Info             |
+----+------+-----------+----+---------+------+-------+------------------+
| 20 | root | localhost |    | Sleep   | 36   |       |                  |
| 23 | root | localhost |    | Query   | 0    |       | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+
You can use this command effectively to debug any performance issue and identify the query that is causing problems, by running the command automatically every 1 second as shown below.
# mysqladmin -u root -ptmppassword -i 1 processlist
+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host      | db | Command | Time | State | Info             |
+----+------+-----------+----+---------+------+-------+------------------+
| 20 | root | localhost |    | Sleep   | 36   |       |                  |
| 23 | root | localhost |    | Query   | 0    |       | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+

+----+------+-----------+----+---------+------+-------+------------------+
| Id | User | Host      | db | Command | Time | State | Info             |
+----+------+-----------+----+---------+------+-------+------------------+
| 24 | root | localhost |    | Query   | 0    |       | show processlist |
+----+------+-----------+----+---------+------+-------+------------------+

8. How to create a MySQL Database?

# mysqladmin -u root -ptmppassword create testdb

# mysql -u root -ptmppassword
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 705
Server version: 5.1.25-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| sugarcrm           |
| testdb             |
+--------------------+
4 rows in set (0.00 sec)


Note: To display all tables in a database, total number of columns, row, column types, indexes etc., use the mysqlshow command that we discussed in our previous articles.

9. How to Delete/Drop an existing MySQL database?

# mysqladmin -u root -ptmppassword drop testdb
Dropping the database is potentially a very bad thing to do.
Any data stored in the database will be destroyed.

Do you really want to drop the 'testdb' database [y/N] y
Database "testdb" dropped

# mysql -u root -ptmppassword
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 707
Server version: 5.1.25-rc-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| sugarcrm           |
+--------------------+
3 rows in set (0.00 sec)

Friday, 21 September 2012


How To Add New Disk To The Hardware Raid Controller Without Rebooting The Server In Linux:


First find out your RAID hardware as we will need appropriate OS utility to manage the same
from the same vendor. In our case it was lsi which can be managed via Megacli utility.

[root@server 8.02.21_Linux_MegaCLI]# lspci | grep -i raid
07:00.0 RAID bus controller: LSI Logic / Symbios Logic MegaRAID SAS 2108 [Liberator] (rev 05)
Lets first install the utilty :
To do this we need to install the Megacli utility on our server Centos6.2.

Step:1. Install the below two packages.
(downlaod from http://www.lsi.com/downloads/Public/MegaRAID%20Common%20Files/8.02.21_MegaCLI.zip) .
#rpm -ivh Lib_Utils-1.00-09.noarch.rpm
#rpm -ivh MegaCli-8.02.21-1.noarch.rpm

Step:2. By default the utility is placed at location as below..
[root@server 8.02.21_Linux_MegaCLI]# cd /opt/MegaRAID/MegaCli/
[root@server MegaCli]# ls
install.log MegaCli64 MegaSAS.log

Step:3. Run the below command before adding the brand new disk drive.
[root@server MegaCli]# /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll | grep -e “Enclosure Device ID” -e Slot
Enclosure Device ID: 252
Slot Number: 0
Enclosure Device ID: 252
Slot Number: 1

Step:4. Run the command again after injecting the new HDD in drive slot.
[root@server MegaCli]# /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aAll | grep -e “Enclosure Device ID” -e Slot
Enclosure Device ID: 252
Slot Number: 0
Enclosure Device ID: 252
Slot Number: 1
Enclosure Device ID: 252
Slot Number: 3

Step:5. Now you have the following information the Enclosure Device ID: 252 and Slot Number: 3 for the newly added drive.

Step:6. Once added the new drive will be in foreign state. Give the below command to clear the foreign status.
[root@server MegaCli]#/opt/MegaRAID/MegaCli/MegaCli64 -CfgForeign -Clear -aALL

Step:7. Add the new drive to the desired RAID level by running below command.
#/opt/MegaRAID/MegaCli/MegaCli64 -CfgLdAdd -r0 [252:3] -a0
Options:
-r1 = RAID1
252 = Enclosure Device ID
2 and 3 = Slot Number
-a0 = Adapter
In our case :
-r0 = RAID0
252 = Enclosure Device ID
3 = Slot Number
-a0 = Adapter

Step:8. tail the /var/log/messages for the new disk
sd 0:2:1:0: [sdb] Mode Sense: 1f 00 00 08
sd 0:2:1:0: [sdb] Write cache: enabled, read cache: enabled, doesn’t support DPO or FUA
sdb: sdb1 sdb2
sd 0:2:1:0: [sdb] Attached SCSI disk

Now you can use the new disk as any other normal drive.

Tuesday, 18 September 2012


Find your IP Address on a Mac


Find your IP Address on a Mac

You can find your IP address from the Mac System Preferences:
  • From the Apple menu pull down “System Preferences”
  • Click on the “Network” preference pane
  • Your IP address will be visible to the right, as indicated in the screenshot below
ip address mac
Your IP address is the number listed, in the above case it is 192.168.0.100
Now we’ll cover the more technical approaches to getting your IP address using the Mac OS X command line:

Find your IP Address via the Mac OS X Terminal

This is how to find the IP address of your Mac through the Terminal, this is often the quickest way for those that are more technically inclined.
  • Launch the Terminal located in /Applications/Utilities/
  • Type the following command:
ifconfig |grep inet
  • You will see something that looks like this:
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
inet6 fe80::fa1e:dfff:feea:d544%en1 prefixlen 64 scopeid 0x5
inet 192.168.0.100 netmask 0xffffff00 broadcast 192.168.0.255

How to Install the Android SDK on Windows XP and Create an Application that Runs in the Cell Phone Emulator:

1. Download and Install the Android SDK and Test the Emulator

2. Install Java 
3. Install Eclipse 
4. Install the ADT Plugin in Eclipse  
5. Create Hello World Applicatio

1. Download and Install the Android SDK and Test the Emulator


We will first go to the Android site and download the SDK
1.
Goto code.google.com/android/download.html and click on theandroid_sdk_windows... link.
download link

2.
Unzip the SDK where you downloaded it.
unzip sdk
post comment or question
3.
Copy all unzipped files to c:\android.
to c android
post comment or question
4.
Set your PATH environment variable by doing this: start > settings >control panel > system > advanced > environmental variables , in theSystem Variables box, click Path and the  Edit  button, then go to the end of you PATH variable, and type ;c:\android\tools and then click  OK  ,  OK  ,  OK  .
android path
post comment or question
5.
Click on start > programms > accessories > command prompt and typeemulator and hit  ENTER  , in a couple seconds the emulator will appear, leave the check checked and click  Proceed .
emulator show
aaronferrucci: If your computer is old/slow, it may take a while for the emulator to come up. Enjoy the cylon display while you wait.
arrow pointing right
reply
Joe: In my command prompt, I get an error message "Cannot create data directory: .... please specify a writable directory with -datadir. Any help?
arrow pointing right
Jeff: I was able to get it working by specifying a directory via -datadir I used c:\android\temp\
arrow pointing right
Paul: Me too... I created them manually, which allowed the emulator to start, but all it says is "A N D R O I D " and won't do anything else...
arrow pointing right
David: Paul I have the exact same thing, any work arounds?
arrow pointing right
Girish: I created a temp dir. But still tat doesnot work
arrow pointing right
Girish: it says "A N D R O I D " and and i cant use anything else...
arrow pointing right
Jim: I did this as well it got to the "A N D R O I D" part. I had to wait about 1 full min for it to respond. It did.
arrow pointing right
NAF: I got the same 'ANDROID' display. But after waiting a while, my app finally ran (I got Core 2 Duo 1,8GHz). Maybe just be a little patient, it takes some time.
arrow pointing right
Jess: I'm still not sure how you create them manually could i get someone to explain a little more? thanks
arrow pointing right
jess: I mean I got c:\android\tools but i still don't know where to go from there to get the emulator.exe to run
arrow pointing right
Hamed: for the error in command prompt ""Cannot create data directory: .... please specify a writable directory with -datadir." I created the directories mentioned in the path above this error manually. for example the path for me was like this: "C:\Documents and Settings\Administrator\Local Settings\Application Data\Android\SDK-1.0" then u just need to go to MyComputer and follow this path "C:\Documents and Settings\Administrator\Local Settings\Application Data\" then there creat the new folder "Android", go to Android folder and creat the new folder "SDK-1.0" . then just go to command prompt and type emulator. it worked for me like this and the Android Emulator appeared on the screen. but u have to wait a little bit till the menu appear after android logo. hope this helps :)
arrow pointing right
sikus: I did in folder "SDK-1.0" .bat file and there I wrote "-datadir C:\android\". This is folder where I have unzip SDK for Android.
arrow pointing right
reply
PW: Jess: Create them manually in the command prompt by typing the following: C:\>emulator -datadir c:\android\temp reply
post comment or question
6.
Click on the browser button.
click browser
post comment or question
7.
Click on the "quick links" icon and press  a .
click quick links
post comment or question
8.
Type in a website address you want to view and press  ENTER .
view it
post comment or question


2. Install Java
To run Eclipse we first need Java so we will download and install it now.
1.
Goto developers.sun.com/downloads.
sun site
Stone Deft: At this point apache mysql and phpmyadmin is already installed and you can skip this step if you prefer to use dreamweaver or other php editors other than eclipse
arrow pointing right
reply
post comment or question
2.
Click on the Java SE (JDK) 6 link.
download jdk
uninstall: I have 2 java programs running and I can't uninstall one of them because it says there was a fatal error when installing it
arrow pointing right
reply
Joel: I'm pretty sure you only need a JRE to run Eclipse, not the full JDK.
arrow pointing right
BitJunky: JDK 5 or JDK 6 (JRE alone is not sufficient) http://code.google.com/android/intro/installing.html
arrow pointing right
reply
post comment or question
3.
Click on the  Download  button for JDK 6u1.
jdk6u1
krisavi: I clicked it and it gives me that download server is down, where I can download JDK 6u1 then?
arrow pointing right
Edward: I just tried it and got "Notice: We're Offline for System Upgrades" as well. Just wait a bit and try again.
arrow pointing right
reply
Ward Christensen: Only offers 6u2 07/08/07. 6u1 SDK EE stilll there. I'm going to DL 6u2 (and I was impressed how up-to-date all the comments so far have been!) This is WONDERFUL!
arrow pointing right
reply
Johnny: I can't find any 6u1 or 2 there.
arrow pointing right
student: i did the 6u4 one
arrow pointing right
himanshu: JDK 6 Update 6 is the latest. sincerely, Himanshu.
arrow pointing right
Hamed: if it has the explanation which says : "The Java SE Development Kit (JDK) includes the Java SE Runtime Environment (JRE) and command-line development tools that are useful for developing applets and applications." thats enough. for example i downloaded the Java SE Development Kit (JDK) 6 Update 10.
arrow pointing right
reply
lini: i cant find jdk 6u1
arrow pointing right
reply
steve: jdk-6u7-windows-i586-p.exe #sept-27th-08#
arrow pointing right
reply
Qn: JDK 6u7 the newest one.
arrow pointing right
reply
AH: i cant find jdk 6u1 either.
arrow pointing right
reply
post comment or question
4.
Click Accept.
click accept
post comment or question
5.
Click on Windows Offline Installation, Multi-language.
offline version
Chill: This is the message i get when i try to download it, "There are no 64-bit versions of the Java Plugin, Java Web Start or Java Control Panel; however the 32-bit versions of the JRE can be installed on 64-bit systems in order to obtain this functionality. Note that only 32-bit browsers are supported at this time." What to do now??? reply
post comment or question
6.
Click  OK  to save it to disk.
save to disk
post comment or question
7.
Save it to C:\download\java6.
download java6 directory
Johnny: You make a your own folder first right?
arrow pointing right
Edward: Right, the main thing is that you just download it somewhere and execute it.
arrow pointing right
reply
post comment or question
8.
Wait a couple minutes.
couple minutes download
post comment or question
9.
After it has finished downloading, you will have this file in your directory.
downloaded
post comment or question
10.
Double click on file that was downloaded.
click on download
Michael: I clicked it and I got 'To Restart Installer, Please Refresh The Webpage'
arrow pointing right
reply
Samantha: I also have the same problem.. reply
post comment or question
11.
Accept agreement.
accept agreement
post comment or question
12.
Click  Next  and it will install for about 8 minutes.
next installing
post comment or question
13.
Unclick the Show the readme file checkbox and click  Finish .
wizard completed
post comment or question



3. Install Eclipse
Eclipse is a professional editor normally used for Java. We will install it in this step and then install the PHPEclipse plugin so we can use it with PHP.

1.
Goto www.eclipse.org/downloads and click Eclipse IDE for Java Developers.
eclipse for java
Karl K: Hmmm... If I have Eclipse installed, having followed the PHP Quick Install tutorial, do I need to create a totally separate android (Java-based) development environment? The bundled packages seem to hinder creation of combined/hybrid eclipse installs.
arrow pointing right
Edward: Theoretically you could have one eclipse and just switch the perspectives between PHP and Java, but my experience is that conflicts occur. The great thing about eclipse is it is not INSTALLED per-se so you can just have a c:\eclipsePhp and a c:\eclipseAndroid and start the one you need, and you can even have both open at the same time, a nice feature.
arrow pointing right
reply
remish: i have already eclipse with me, only i want to add the android plugins but it is giving error of RCP.how i can resolve it? reply
post comment or question
2.
Click on the suggested mirror link.
pick eclipse mirror
post comment or question
3.
Click "Save to Disk" and click on  OK .
save eclipse
post comment or question
4.
Unzip the Eclipse file that you downloaded.
unzip eclipse
post comment or question
5.
Type in c:\ and click  OK  (this will create a directory called c:\eclipse and unpack everything there.
unzip to c
post comment or question
6.
Double-click on the file c:\eclipse\eclipse.exe.
start eclipse
post comment or question
7.
Set the workspace to C:\androidApps , click the checkbox, then click  OK .
android apps
post comment or question
8.
Click on the workbench icon.
goto workbench
Himanshu: Why this step may I ask ? You just tell to click here and then next step says to exit. just curious,
arrow pointing right
Jo: think about it
arrow pointing right
reply
russell adkins: Maybe to make sure it works?
arrow pointing right
reply
post comment or question
9.
Close Eclipse by clicking on the X.
close eclipse
post comment or question
10.
Click the checkbox and  OK .
close eclipse2
post comment or question



4. Install the ADT Plugin in Eclipse
This plug-in (Android Development Tools) will make creating applications for Android easier so we will install it now.

1.
Start Eclipse and then click Help > Software Updates > Find and Install....
find and install
Thakgatso: i dont have the "Find and intall.." option. I only have the Software Updates...The menu does not extend.
arrow pointing right
reply
Tapan: Even I don't see "Find and install" option. I only have the "Software Updates...." I have downloaded the latest Eclipse version 3.4 and installed. reply
Clement: The sub menus under Software Updates no longer shows Click on the available software tab Then click on add site Add: https://dl-ssl.google.com/android/eclipse You will see the two packages listed
arrow pointing right
Skipper: I get an error saying: No repository found at https://dl-ssl.google.com/android/eclipse
arrow pointing right
Skipper: fixed, just had to use "http" instead of "https"
arrow pointing right
reply
post comment or question
2.
Click the Search for new features to install choice and then click  Next .
search install
post comment or question
3.
Click the  New Remote Site...  button.
new remote site
post comment or question
4.
In the Name box type Android Plugin and in the URL box type https://dl-ssl.google.com/android/eclipse, then click  OK .
android plugin type
filbert: In Eclipse it results in the following error: No repository found at https://dl-ssl.google.com/android/eclipse/ In a browser it results in a 404. Changing to http:// makes no difference.
arrow pointing right
reply
post comment or question
5.
Make sure Android Plugin choice is checked and click  Finish .
check and finish
post comment or question
6.
Check the Android Pluging choice again and click  Next .
click android and next
Santhosh: After clicking on Next,i am getting an pop-up saying IO EXception.PLease provide a solution to my exception. reply
remish: when i am selecting the checkbox its showing the error "Current configuration problems". how i can resolve this. reply
post comment or question
7.
Check the I accept the terms in the license agreement choice and click  Next .
click i accept
post comment or question
8.
Click  Finish .
click finish now
post comment or question
9.
Click  Install All .
click install all
post comment or question
10.
Click  Yes  to restart Eclipse.
click yes restart
post comment or question
11.
When Eclipse starts again, click Window > Preferences....
windows preferences
Joel: The default font size really is fine if you're using a modern, high-res, monitor. If you're still in 1024x768, I can see why you'd want smaller characters though.
arrow pointing right
reply
indeed: this should perhaps been marked as optional? at 1920x1200 this will give me REALLY small letters xD reply
post comment or question
12.
Click Android then  OK .
android then ok
Francis Cagney: I've followed all these steps exactly to here, but at this point no android preferences appears on the left. If I try and re download android adt it say its already there. Below are the only tabs visible General C/C++ Help Install/Update Run/Debug Team
arrow pointing right
Francis Cagney: Actually I've solved it. I was download Ecliple for C++ instead of exclipse for java. Surprised some part of the Eclipse/android interaction dind't point out what was wrong. Still thanks to Edward Tanguay for writing a superb tutorial. Gonna enter the google competition?
arrow pointing right
Omar: Yeah Edward. Would like to know if you are planning to take part in the Android App Contest.
arrow pointing right
reply
selva: I dont get android preference on the left . someone please help me.
arrow pointing right
yogesh: I am getting the error when i enter path of tools for android. C:\android-sdk_m5-rc15_windows\tools [2008-03-17 01:51:40 - adb] Failed to get the adb version: Cannot run program "\tools\adb.exe": CreateProcess error=3, The system cannot find the path specified [2008-03-17 01:52:21 - adb] * daemon not running. starting it now * Also i have observed that i am not getting check box automatic sync project to current SDK email :- yogeshsdsu@gmail.com . I am going to start working on a project on andoid. I will be thankfull if Edward .
arrow pointing right
reply
post comment or question
13.
Click  Browse...  then navigate to c:\android and click  OK .
browse and find
post comment or question
14.
Click  Apply  and then  OK .
apply ok
post comment or question

5. Create Hello World Application
This will show you how to make a simple application with Eclipse.
1.
Click File > New > Other....
file new other
post comment or question
2.
Click on Android Project and  Next .
android and next
post comment or question
3.
Fill out the form and click  Finish .
fill finish
post comment or question
4.
Change the code in HelloWorld.java to the following.
change code
pcor59: Hallo, with last SDK I had to modify java source with 2 import: import android.os.Bundle; import android.widget.TabTextView; and I had to replace TextView with TabTextView. All worked. Thank you very much for your great Tutorial, all the best and have a nice 2008.
arrow pointing right
Andy: Hi pcor59, I'm using the latest SDK. How do I modify java source with the 2 import you mentioned?
arrow pointing right
reply
Andy: Hi Edward! You site had very good tutorials! I'm using the latest SDK and I'm getting an error something like "TextView cannot be resolved to a type" pointing to line 10 of the code. I'm excited to see my first Hello World program. Appreciate your help!
arrow pointing right
Rod: I hope this isn't posted too late but I got the same error. The solution I accidentally happened upon: Adding the following under 'import android.app.Activity; ... import android.os.Bundle; import android.widget.TextView; This solved my problem... :-\
arrow pointing right
reply
Ronen: i just read on the notepad tutorial , that pressing ctrl+shift+o can automatically add missing imports for you. tried it here and it worked. so instead of writing import line you can press those keys. reply
post comment or question
5.
Click Run > Open Run Dialog....
open run dialog
post comment or question
6.
Click on Android Application, then on the add icon, fill in Name, Project and Activity and press Next .
six steps
post comment or question
7.
In about 20 seconds you will see your application appear in the emulator.
in emulator
KenR: Excellent tutorial. Thank you so much for making everything so easy to get started. You are the man!
arrow pointing right
Harpreet: Great tutorial to start , havent seen better than this
arrow pointing right
reply
Gaurav: Excellent Tutorial....All Done in really easy steps... :) reply
LC: Excellent, yes! verry easy! Now, since I am a greenie at this, please point me toward a site that will tell me what it is I just did??? I get the emulator, not sure about eclipse and what it means to create applications. Thanks much :) reply
judy: Superb Tutorial. reply
Vishal Singh: Awesome tutorial. But emulator is old. reply
ekambresh: Excellent tutorial i was facing lots of problem while installing eclipse with adt plugin. u made it easy thanks a lot.it will be better post some tutorial regarding android. reply
Hebs: Hey thanks for this tutorial. I tried all week to get the sdk working in Ubuntu 7.10 but failed. I am getting dependency errors when installing the ADT plugin in Eclipse. I guess this is one more thing I will have to restart to Windblows for : / reply
Rod: Amazing... I followed through and this worked! I am so happy I didn't crash and burn. :-) reply
sunny: very well put together and worked perfectly reply
mrbahl: Hello, Amazing tutorial Sir ! Good job.. you deserve a letter of thanks from the eclipse and google team. :-) reply
Thakgatso: Thanks for this tutorial, it helped me a lot. I dont seem to get the 4th step right. i cant get the Eclipse to install the android SDK from the Help>>Install updates reply
siddharth khimsara: a very good and easy to-the-point tutorial...hats off!! reply
Justin: Spot on - installation a bit dated, used this from Google http://code.google.com/android/intro/installing.html and then followed the Hello World tutroial here and it worked fine. Thanks very much! reply
Doctor: Great tutorial. Really helped me. reply
Mukaram: Thanks. Got me started in no time. reply
raykin: Thanks, very good tutorial. Saved me a lot of time. reply
Hamed: a really great and usefull step by step tutorial! tnx so much, keep it up :) reply
post comment or question