Showing posts with label Technology. Show all posts
Showing posts with label Technology. Show all posts

Interview Preparation mysql dba interview questions

 


Are you a DBA in one particular discipline say Oracle, SQL Server, MySQL. Way back 10 years if you know any one of these you are good to go. Your job is guaranteed for another few years. Now the IT demographics has been shifting continuously and its time to rethink about the future if career. The way data is handled has drifted from conventional relational model to latest unstructured model. To handle such humongous volume of data which grows big day by day it becomes mandate to start learning the NoSQL databases that handle big data. MongoDB is a popular NoSQL database brand that is gaining popularity at lightning pace.MySQL relational database is growing at rapid pace in addition to oracle for supporting websites.

MySQL the most popular open source database was acquired by Sun microsystems. Later Oracle corporation acquired Sun. Now Mysql is popular among website companies owing to its flexibility. Owing to its scare availability of mysql DBA's it is a hot skill. Moe than 1200+ practical mysql dba interview questions will be updated soon.

What does mysql dba do?

MySQL is gaining popularity among the web developers community owing to its ease of usage and low cost.We are going to discuss more posts on various tasks performed by MySQL DBA. We'll be updating details on the following MySQL DBA responsibility details, information on MySQL database and many more :

1) Connecting And Disconnecting From MySQL

2) Issuing MySQL Commands

3) Creating and using database in MySQL

4) Create user in MySQL

5) Drop user in MySQL

6) Using MySQL utilities like mysqladmin, mysqlimport and many more

1) How do I access mysql database?

We can invoke mysql comman-line interface by simply typing  mysql at the command prompt. The command is the same for windows and Linux

2) How can you get details on databases?

The command show database; helps us get information on the mysql databases

MySQL on Linux Database Common tasks:-

Log Into MySQL Server Ubuntu Linux :

We've seen steps on installing mysql server in ubuntu linux, checking if mysql service is up and running. We can log into mysql server using the root user and password.

root@ubuntu:~# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 39

Server version: 5.1.41-3ubuntu12.6 (Ubuntu)

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql>

MySQL Database Create Use Ubuntu Linux :

First step in using a mysql database is creating a new database. We need to use it next. In this database we can create tables, index,procedures and such database objects.This is in mysql ubuntu linux.

mysql> create database test;

Query OK, 1 row affected (0.00 sec)

mysql> use test;

Database changed

Mysql pi() Function Ubuntu Linux :

In ubuntu linux we can make use of scientific functions. These are also called mathematical functions. Here is how we use the function


mysql> select pi();

+----------+

| pi() |

+----------+

| 3.141593 |

+----------+

1 row in set (0.00 sec)

mysql> select pi() * 2;

+----------+

| pi() * 2 |

+----------+

| 6.283185 |

+----------+

1 row in set (0.00 sec)

Mysqlcheck Command Test Table:

We can test the tables in a mysql database using the mysqlcheck utility. As we've set the password we need to supply the password using -p option while using this command from shell. Mysqlcheck is used to check, repair the tables in a database.Here is how it works

root@ubuntu:~# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 48

Server version: 5.1.41-3ubuntu12.6 (Ubuntu)

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> use test

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> create table test(id integer);

Query OK, 0 rows affected (0.07 sec)

root@ubuntu:~# mysqlcheck -p test test

Enter password:

test.test OK

Unified Oracle SSO Credentials For MySQL.com Authentication :

Oracle corporation the DB giant has acquired sun microsystems few years back as a part of which MySQL has now become an integral part of Oracle product suite.

Ever since acquisition Oracle has been revamping lot on Sun Solaris, MySQL

As a new move from ORacle corporation it is now possible to use the oracle.com account to log onto mysql.com. Oracle SSO credentials are validated with mysql.com authentication. This helps you have one single account to access multiple portals

This is a marketing strategy from Oracle corporation that projects power of its Oracle SSO suite of products to be used with its own websites.

If you dont have an accoutnwith oracle.com create one and use it with mysql.com

1) How to check Mysql Service in ubuntu Linux?

We can check if the mysql service is up and running in the ubuntu linux using the service command. It is easy and simple as follows:

root@ubuntu:~# service mysql status

mysql start/running, process 32478

2) How to install MySQL in Ubuntu Linux Server?

It is very easy to install mysql in ubuntu linux server.We can simply install the mysql package in the ubuntu linux server very easily. All we need is a apt-get install ubuntu linux command. Here is how it goes about.

root@ubuntu:~# apt-get install mysql-server

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

libdbd-mysql-perl libdbi-perl libhtml-template-perl libnet-daemon-perl

libplrpc-perl mysql-client-5.1 mysql-client-core-5.1 mysql-server-5.1

mysql-server-core-5.1

Suggested packages:

dbishell libipc-sharedcache-perl tinyca mailx

The following NEW packages will be installed:

libdbd-mysql-perl libdbi-perl libhtml-template-perl libnet-daemon-perl

libplrpc-perl mysql-client-5.1 mysql-client-core-5.1 mysql-server

mysql-server-5.1 mysql-server-core-5.1

0 upgraded, 10 newly installed, 0 to remove and 41 not upgraded.

Need to get 21.2MB of archives.

After this operation, 50.4MB of additional disk space will be used.

Do you want to continue [Y/n]? Y

Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid/main libnet-daemon-perl 0.43-1 [46.9kB]

Get:2 http://us.archive.ubuntu.com/ubuntu/ lucid/main libplrpc-perl 0.2020-2 [36.0kB]

Get:3 http://us.archive.ubuntu.com/ubuntu/ lucid/main libdbi-perl 1.609-1build1 [798kB]

Get:4 http://us.archive.ubuntu.com/ubuntu/ lucid/main libdbd-mysql-perl 4.012-1ubuntu1 [135kB]

Get:5 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main mysql-client-core-5.1 5.1.41-3ubuntu12.6 [177kB]

Get:6 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main mysql-client-5.1 5.1.41-3ubuntu12.6 [8,138kB]

Get:7 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main mysql-server-core-5.1 5.1.41-3ubuntu12.6 [4,712kB]

Get:8 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main mysql-server-5.1 5.1.41-3ubuntu12.6 [7,008kB]

Get:9 http://us.archive.ubuntu.com/ubuntu/ lucid/main libhtml-template-perl 2.9-1 [65.8kB]

Get:10 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main mysql-server 5.1.41-3ubuntu12.6 [93.6kB]

Fetched 21.2MB in 35s (606kB/s)

Preconfiguring packages ...

Selecting previously deselected package libnet-daemon-perl.

(Reading database ... 125251 files and directories currently installed.)

Unpacking libnet-daemon-perl (from .../libnet-daemon-perl_0.43-1_all.deb) ...

Selecting previously deselected package libplrpc-perl.

Unpacking libplrpc-perl (from .../libplrpc-perl_0.2020-2_all.deb) ...

Selecting previously deselected package libdbi-perl.

Unpacking libdbi-perl (from .../libdbi-perl_1.609-1build1_i386.deb) ...

Selecting previously deselected package libdbd-mysql-perl.

Unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_4.012-1ubuntu1_i386.deb) ...

Selecting previously deselected package mysql-client-core-5.1.

Unpacking mysql-client-core-5.1 (from .../mysql-client-core-5.1_5.1.41-3ubuntu12.6_i386.deb) ...

Selecting previously deselected package mysql-client-5.1.

Unpacking mysql-client-5.1 (from .../mysql-client-5.1_5.1.41-3ubuntu12.6_i386.deb) ...

Selecting previously deselected package mysql-server-core-5.1.

Unpacking mysql-server-core-5.1 (from .../mysql-server-core-5.1_5.1.41-3ubuntu12.6_i386.deb) ...

Selecting previously deselected package mysql-server-5.1.

Unpacking mysql-server-5.1 (from .../mysql-server-5.1_5.1.41-3ubuntu12.6_i386.deb) ...

Selecting previously deselected package libhtml-template-perl.

Unpacking libhtml-template-perl (from .../libhtml-template-perl_2.9-1_all.deb) ...

Selecting previously deselected package mysql-server.

Unpacking mysql-server (from .../mysql-server_5.1.41-3ubuntu12.6_all.deb) ...

Processing triggers for man-db ...

Processing triggers for ureadahead ...

Setting up libnet-daemon-perl (0.43-1) ...

Setting up libplrpc-perl (0.2020-2) ...

Setting up libdbi-perl (1.609-1build1) ...

Setting up libdbd-mysql-perl (4.012-1ubuntu1) ...

Setting up mysql-client-core-5.1 (5.1.41-3ubuntu12.6) ...

Setting up mysql-client-5.1 (5.1.41-3ubuntu12.6) ...

Setting up mysql-server-core-5.1 (5.1.41-3ubuntu12.6) ...

Setting up mysql-server-5.1 (5.1.41-3ubuntu12.6) ...

mysql start/running, process 32478

Setting up libhtml-template-perl (2.9-1) ...

Setting up mysql-server (5.1.41-3ubuntu12.6) ...

Processing triggers for libc-bin ...

ldconfig deferred processing now taking place

3) Describe some information on dbmail Mysql dependency Package onto ubuntu Linux?

I tried installing mysql database in ubuntu linux and found that some dependency packages have to be installed before installing mysql. dbmail is an interesting package that can be installed in ubuntu linux.

root@ubuntu:~# apt-get install dbmail

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following extra packages will be installed:

libgmime-2.0-2a libsieve2-1

Suggested packages:

dbmail-pgsql dbmail-mysql sqlite3

The following NEW packages will be installed:

dbmail libgmime-2.0-2a libsieve2-1

0 upgraded, 3 newly installed, 0 to remove and 41 not upgraded.

Need to get 594kB of archives.

After this operation, 1,786kB of additional disk space will be used.

Do you want to continue [Y/n]? Y

Get:1 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libgmime-2.0-2a 2.2.22-5 [200kB]

Get:2 http://us.archive.ubuntu.com/ubuntu/ lucid/universe libsieve2-1 2.2.6-1 [76.2kB]

Get:3 http://us.archive.ubuntu.com/ubuntu/ lucid/universe dbmail 2.2.11-1build1 [317kB]

Fetched 594kB in 1s (374kB/s)

Preconfiguring packages ...

Selecting previously deselected package libgmime-2.0-2a.

(Reading database ... 125127 files and directories currently installed.)

Unpacking libgmime-2.0-2a (from .../libgmime-2.0-2a_2.2.22-5_i386.deb) ...

Selecting previously deselected package libsieve2-1.

Unpacking libsieve2-1 (from .../libsieve2-1_2.2.6-1_i386.deb) ...

Selecting previously deselected package dbmail.

Unpacking dbmail (from .../dbmail_2.2.11-1build1_i386.deb) ...

Processing triggers for man-db ...

Processing triggers for ureadahead ...

Setting up libgmime-2.0-2a (2.2.22-5) ...


Setting up libsieve2-1 (2.2.6-1) ...


Setting up dbmail (2.2.11-1build1) ...


Creating config file /etc/dbmail/dbmail.conf with new version


Creating config file /etc/default/dbmail with new version

* Starting dbmail servers [ OK ]


Processing triggers for libc-bin ...

ldconfig deferred processing now taking place

1) How do you find version of mysql?

We can make use of one of the following commands :

mysql –version

mysqladmin –version

mysql>select version();

2) Can we use mysqladmin to start the mysql server?

No. We can’t use mysqladmin to start the mysqld.

3) How do you stop the mysqld(mysql server) using mysqladmin?

mysqladmin -uroot -ppassword shutdown

4) What is the default administrative account in mysql grant system?

The default administrative account is “root”.

5) How do you determine the status of variables?

mysql>show status;

$mysqldmin extended-status

6) How do you obtain information on client processes?

We can obtain list of client processes connected to the server with the following command:

mysql>show processlist;

7) Can a regular user be able to see all process threads?

No.Only users with “PROCESS” privilege can see a complete list. REgular users can see their own threads.

8) What can users with “SUPER” privilege do?

Users with “SUPER” privilege are the most powerful. They can even kill running threads with the KILL command.

mysql>kill thread-number(eg:1,2…);

MySQL TABLE MOVE RENAME DATABASE :

This is a sample test that I performed in my mysql lab today. I created two different databases. I created a new table in one database. I moved it to another database with its name renamed. I tried moving the old table to seconds database with the original name and this gave an error

mysql> create database first;

Query OK, 1 row affected (0.01 sec)

mysql> create database second;

Query OK, 1 row affected (0.01 sec)

mysql> create table first.old (id int);

Query OK, 0 rows affected (0.10 sec)

mysql> alter table first.old rename second.new;

Query OK, 0 rows affected (0.03 sec)

mysql> alter table first.old rename second.old;

ERROR 1146 (42S02): Table ‘first.old’ doesn’t exist

Here are my findings regarding MySQL tables

1) Tables can be moved across two different databases

2) Tables can be renamed while moving from one database to another

3) Original table becomes unavailable after performing MOVE operation

Career Prospects MySQL DBA :-

Mysql the light weight most sought after database used prominently in web application development that is made use of by giants including facebook.com is gaining popularity day by day.

There are plenty of options in Mysql discipline. why am I so particular about mysql DBA?

There is certainly a reason that made me think a lot into this and come to a conclusion on mysql DBA profile.

As companies start migrating towards cloud slowly, the profile that is in danger is the DBA as applications hosted in cloud dont need a DBA to optimize their performance.

When it comes to cloud nosql databases including mongodb is made use of extensively. Considering the resemblance of mongodb with mysql the change of career from mysql dba to mongoDB will be an easy approach to safeguard your career

What is company operates in a non-cloud environment?

Still this light weight easy to maintain that is easily inter-operable with open source programming languages including perl,php,python,ruby on rails that have good drivers developed to support mysql make it the choice of many startups including popular facebook,twitter,tumblr to name a few. Start learning mysql today

Give details on mysql backup types:-

MySQL database the choice of many web techs these days is light weight and offers interesting backup options. Mysql backups can be broadly classified into two major categories:

1) Physical backups - This is copy of files and directories at file system level. This involves backup of datafiles, configuration files of mysql

2) Logical backups - This is an interesting backup that lets you perform backup at logical structure level, create dumps that can be imported against. This doesnt involve backup of physical files and directories

How is MySQL tee Command to spool output to logfile?

In Oracle we make use of spool filename command to spool the output of a sql statement onto an output file. similar to that in mysql we have a command called tee that logs the output of a sql command to output file

tee filename.txt

show variables

The above command will spool the output to a file called filename.txt

In Oracle the above command equivalent will be

spool filename.txt

show parameter parametername

spool off

Why MySQL Is Becoming Hot?

Ever since acquisition of Sun microsystems by Oracle corporation, Mysql the open source database is gaining momentum as opposed to what has benn thought originally. Considering the open source popularity Oracle has rebranded it as Oracle MySQL

These days if you look at job requirement it is a combo skill that employers are looking for. MySQL is definitely a keyword that will be a mandate. some employers are willing to train their employees and are looking for passion to learn MySQL

Being so small, simple, having small footprint, tight integration with web scripts like PHP/Perl, easy maintenance and lots of interesting features has made MySQL a red hot skill that can come as a great secondary skill as DBA and developer

Corporates are in cost cutting mode and this has made them turn their focus on open source technologies and framework that is free. Some of the technologies that offer same interesting feature as their licensed counterparts are in great demand

In programming arena, OOP also called the object oriented programming is the base on which big technological giants including google, facebook are built.

Considering this it is always a good idea to learn a free open source programming language. Java is most popular and is exhaustive. To cater to growing demand companies go behind agile techniques both in project management as well as technology architecture choice. This has led to choice of scripting languages like Ruby on rails, PHP/Mysql stack, python, perl over java, .NET

If you prefer to land in your next dream job at twitter, facebook, google don't wait today. Grab a PHP/MySQL, javascript book from your library and start learning today

How to change column datatype of table in mysql?

Whenever we create a table in a mysql database, we can later change the datatype of the table column as follows

alter table tablename change columnname columnname newdatatype;

Give details on built-in functions in mysql?

There are plenty of functions in-built in mysql database that helps us obtain information on user, hostname, day,time,day of the year. We can connect using mysql client as root user and password. Here is a simple set of inbuilt function demonstration.

mysql> select dayofyear('2010-09-09');

+-------------------------+

| dayofyear('2010-09-09') |

+-------------------------+

| 252 |

+-------------------------+

1 row in set (0.00 sec)


mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

+--------------------+

2 rows in set (0.00 sec)


mysql> select curdate();

+------------+

| curdate() |

+------------+

| 2010-09-28 |

+------------+

1 row in set (0.00 sec)


mysql> select current_time();

+----------------+

| current_time() |

+----------------+

| 11:32:35 |

+----------------+

1 row in set (0.00 sec)


mysql> select current_user();

+----------------+

| current_user() |

+----------------+

| root@localhost |

+----------------+

1 row in set (0.00 sec)

Give details on MySQL Tables Database Information Schema:-

In MySQL database whenever we log into it as a root user, we land in the default database information_schema. From there we can list the tables in all other databases within the system. Here are simple steps demonstrating this process

mysql> create database infopedia;

Query OK, 1 row affected (0.01 sec)

mysql> show tables from infopedia;

Empty set (0.00 sec)

mysql> use infopedia;

Database changed

mysql> create table new (id INT);

Query OK, 0 rows affected (0.03 sec)

mysql> use information_schema;

Database changed

mysql> show tables from learnermydbsreference;

+---------------------+

| Tables_in_mydb |

+---------------------+

| new |

+---------------------+

1 row in set (0.00 sec)

MyISAM Table InnoDB MySQL Database:-

If you'd have tried creating tables in a mysql database under the C:mysqldata directory you will see folders corresponding to the database created. Lets say if we create a new database named infopedia using mysql command :we see a folder named mydb created under C:\mysqldata. It will be of form C:\mysqldata\mydb

Inside this folder we see a file named db.opt . This file is of type OPT (I make use of Windows OS) and stores details on the characteristics of database.

Now comes the interesting concept of database engine. Some popular MySQL database engines are - MyISAM, InnoDB, Memory, ARCHIVE,MGR_TARGET. If we make use of GUI phpMyadmin we get this options as a drop down menu while creating table. Each storage engine has its unique benefit. Two most popular storage engines are Myisam and innodb. By default if a table is created in a database it is assigned engine=myisam. If we want to create a table of type innodb we need to specify the option engine=innodb while creating the database.

mysql> use mydb;

Database changed

mysql> create table test_myisam(id int) engine=myisam;

Query OK, 0 rows affected (0.02 sec)

The above query will create a table of type myisam. There will be three files test_myisam.frm, test_myisam.MYD, test_myisam.MYI created under the folder infopedia directory (C:mysqldatainfopedia location)

mysql> create table test_innodb(id int) engine=innodb;

Query OK, 0 rows affected (0.01 sec)

This query creates a table of type innoDB. We see file of form test_innoDB.frm under the mydb directory (C:\mysqldata\mydb location)

phpmyadmin mysql date error:-

I make use of phpmyadmin interface to create a table with column todaysdate of datatype date. I tried setting default value using current_date() and now() functions. I got the error.Later I found that date values are assigned by default.

phpMyAdmin MySQL GUI Engine Types:-

phpMyAdmin is a GUI tool that makes creation and management of mysql database objects very easy and user friendly. This is a graphical demonstration of storage engine types. By default MyISAM tables are created. innoDB is another interesting storage engine type.

MySQL Prepared Statements:-

MySQL Prepared Statements are used when we want to execute mny SQL statements tht differ slightly.They are comparable to substitution variables in ORacle where the value is passed on during run-time.They are very efficient as parsing of query is done once and values are substituted dynamically.

A good example on prepared statement is given below :

1) mysql>prepare preparestatement_name from 'query';

Say,

mysql>prepare my_example from 'select count(*) from emp where dept = ?';

2) mysql> set @dept='value'; execute my_example using @dept;

3) mysql> DEALLOCATE PREPARE my_example;

Following are the sequence of steps followed :

1) Create and name prepared statement. The FROM clause is followed by query.

2) Set the dynamic vriable value.

3) Execute the prepared statement.

4) Deallocate the prepared statement.

Mysql my.cnf my.ini my file:-

I tried configuring replication in my MySQL database instance. I had WAMP installed in my laptop and MySQL has come as an integral part of it. For enabling replication the it is essential to enable binary logging, set server-id in the my.cnf (or) my.ini file. I was looking out for this file but couldn't find one. I instead found my file under C:mysql. I made changes to this file (this can be done by shutting down the mysql server instance first). Then I restarted the instance.

MySQL Default Databases List :

In a mysql database there are few default databases created at the time of installation. If we connect as root user and get the list of databases we get the following result

mysql> show databases;

+----------------------------+

| Database |

+----------------------------+

| information_schema |

| mysql |

+----------------------------+

2 rows in set (0.04 sec)

1) How do you find version of mysql?

We can make use of one of the following commands :

mysql --version

mysqladmin --version

mysql>select version();

2) Can we use mysqladmin to start the mysql server?

No. We can't use mysqladmin to start the mysqld.

3) How do you stop the mysqld(mysql server) using mysqladmin?

mysqladmin -uroot -ppassword shutdown

4) What is the default administrative account in mysql grant system?

The default administrative account is "root".

5) How do you determine the status of variables?

mysql>show status;

$mysqldmin extended-status

6) How do you obtain information on client processes?

We can obtain list of client processes connected to the server with the following command:

mysql>show processlist;

7) Can a regular user be able to see all process threads?

No.Only users with "PROCESS" privilege can see a complete list. Regular users can see their own threads.

8) What can users with "SUPER" privilege do?

Users with "SUPER" privilege are the most powerful. They can even kill running threads with the KILL command.

mysql>kill thread-number(eg:1,2...);

9) How to log into mysql database?

Logging into MySQL is done using username and password. In addition to this we need to specify the hostname - name of the machine where the MySQL server runs.

mysql ---- client program used to connect to the mysql server.

mysql -uusername -ppassword -hhostname

The syntax mentioned above is used to connect to a mysl server.

where,

username - name of the user

password - password

hostname - host where server resides

10) How to check is server is up and running using mysqld command?

Mysqladmin is the tool popular among the mysql dba's primarily used for database administration purpose. We can use the ping option to see if mysqld is alive or not.

root@ubuntu:~# mysqladmin -uroot -p ping

Enter password:

mysqld is alive

11) Give details on mysql architecture:-

MySQL Architecture is a client server architecture where server runs on one machine and client connects to the server machine.The server daemon is mysqld which is started in server with many different options.

There are many ways to check if a mysqld is up and running.

In an UNIX machine issue the following command:

ps -efgrep mysqldgrep -v mysqld

In windows navigate :

Control Panel->Administrative Services->Services->MySQLService(name given at the time of creation of mysql service).Check the status of service. If it is start we can start using the system.

12) What are the methods to perform backup in mysql database:-

MySQL Database Backups are made by DBA to safeguard the database against the possibility of system crash or hardware failure that may result in a data loss or corruption.

Backups are used as a protection against human errors like database and table removal by mistake

We set move MySQL installation from one server to another, set up a replication server we need a backup of the database

13) Give details on Shell Script to test and start mysql server:-

This is the shell script to test if the mysql server is up and running. If so ignore it. If not we can start the mysqld daemon.

#!/bin/sh

process=`ps -U mysql|wc -l`

results=`ps -U mysql > new`

res=`sed -n 2p new`

echo Result is $res // checkpoint

echo $process

if [ $process -lt 2 ]; then

echo "Start the server"

service mysqld start

else

echo "Server already up and running"

fi

14) What is the reason behind Warning: mysqli_connect() [function.mysqli-connect]: (42000/1049): Unknown database 'databasename' in 'path' on line x?

Warning: mysqli_connect() [function.mysqli-connect]: (42000/1049): Unknown database 'databasename' in 'path' on line x

Error message specified in die function of mysqli_connect where x=1,2,3...

mysqli_connect ( ) is the PHP function used for establishing connection between PHP script and mysql database....

mysqli_connect("hostname","username","password","databasename") or die ("Error Message" );

Eg :

mysqli_connect("hostname","username","password","databasename") or die ("Not Found" );

This error occurs if a wrong databasename or a database that is non existant is specified in databasename part.

It is a good practice to use die ( )  function to catch the errors and display messages.

15) What is the reason behind ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)?

I had WAMP installed in my laptop. I tried connecting to mysql database by issuing mysql and got the error ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061). I thought that the problem is with root password. On careful examination I found that the WAMP server is down. I again restarted WAMP server and the problem got fixed. The major flexibility with using WAMP is that we can manage each services (Apache,PHP,MySQL) individually though they come together as a single bundle.

C:wampbinmysqlmysql5.1.36bin>mysql -uroot -p

Enter password: ********

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

C:wampbinmysqlmysql5.1.36bin>mysql -uroot -p

Enter password: ****

Welcome to the MySQL monitor. Commands end with ; or g.

Your MySQL connection id is 1

Server version: 5.1.36-community-log MySQL Community Server (GPL)

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql>

This works fine now.

Mysqladmin command line tool usage:

MySQL Database ,the open source database widely used today because of its cost-effective nature is gaining momentum.Organizations are migrating from different databases to MySQL.

MySQL is on 5.1 release and have come out with 6.0 beta version.MySQL has its own certification programme geared towards developers and DBA's.We will be discussing on MySQL.

The command-line tool used for MySQL server administration is mysqladmin.

Loction : /usr/local/mysql/bin/mysqladmin

Few Uses :

1) Perform mysql administration tasks such as shutdown

2) Reload mysql privileges ( mysql grant tables)

2) user administration ( changing mysql administrator password)

Usage : mysqladmin command

command can be one of the following:

reload - reloads mysql grant tables

status - server state information

ping - test if server is alive

shutdown - shutsdown the mysql server

refresh - resets all caches and logs

variables - returns value of all server variables

processlist - returns list of all processes active on the server

kill - kills an active session process

version - display mysql server version

password - changes a user password

To obtain help on mysqladmin usage issue : mysqladmin --help

GUI lternatives of mysqladmin :

Tasks performed by mysqladmin tool can be performed by certain GUI ( Graphical User Interface) tools

1) pnpMyAdmin

2) Mysql control center

3) Winmysqladmin

How can you get details on warnings CREATE TABLE IF NOT EXISTS Table_name Command?

1) Log into the MySQL Database Server from command-line client mysql/phpMyAdmin :

$mysql -u root -ppassword

mysql>

2) List the databases and choose the database. If it is a fresh install, create a new database.

mysql> show databases; - Lists databases

mysql> use database_name; - Where database_name is the name of database we use. Say firstexample is the name of the database :

mysql> use firstexample;

mysql> show tables; - Lists tables in firstexample

If no database exists, create a new database and use it.

mysql> create database firstexample;

mysql> use firstexample;

mysql> show tables;

3) Create a table with a unique name. Check if the table with samename already exists:

mysql> create table if not exists table_name;

We get Warnings, if table with samename already exists and the table doesn't get created.

4) To get more details on warnings, use :

mysql> show warnings;

Level : Note

Code : 1050

Message : Table 'table_name' already exists


How to change root password of mysql database? I've recently installed WAMP Server in my laptop. MySQL comes as a part of WAMP (Windows+Apache+MySQL+PHP). I'll be blogging interesting articles on MySQL database administration, development. Here is the first post on changing root password in MySQL database. Invoke mysql executable and login as root user. It will have no password set initially C:mysql -uroot -p mysql> use mysql mysql> update user set password=PASSWORD("pass") where User="root"; Query OK, 2 rows affected (0.07 sec) Rows matched: 2 Changed: 2 Warnings: 0 mysql> flush privileges ; Query OK, 0 rows affected (0.02 sec) mysql>quit It is different than Oracle. Here we update value in admin table user.

Interesting Websites Software

Google Apps For Education:
Google Apps For Education is an google apps edition geared towards schools and universities. Google apps for education offers a set of customizable tools that helps faculty and students help together more effectively. Google apps for education is absolutely free. Following are the features included in google apps for education
1) Gmail
2) Google calendar
3) Gtalk/Google Talk
4) Google Documents
5) Google Sites
6) Google Video
7) Several API's
64bit itunes installer Windows 7 :
iTunes is needed to make use of podcasts these days. the default installer we find is the 32-bit installer. Some system architecture requrie 64-bit itune installer. I found this 64-bit installer from the following website.
http://support.apple.com/kb/DL1047
Is it Raining Now Website Interesting :
I wanted to blog details on some interesting websites. It is change of weather and it is raining here. In MSN we have a widget to dynamically update(weather) conditions and it is implemented based on AJAX technology. I did a simple research on interesting weather reporting websites
It it Raining Now?Enter the name of your place and get to know if it is raining there. This is very simple and cool
What is the weather now?
You can get to know what the weather condition is. Also, you can get a forecast one month well in advance and plan your trips
Compressing And Uncompressing A File Using bzip2 an bunzip2 utility:
bzip2 utility compresses a file by analyzing it and recording it more efficiently.It works well particularly on files that contain repeating information, such as text and image data, although most image data is already in compressed format.
Steps in using bzip2 utility :
1) Obtain information about the file
ls -l
2) The --verbose(-v) optionncauses bzip2 to report how much it will be able to reduce the size of the file
bzip2 -v file_name
3) obtain file information
ls -l
While executing the above command we find that .bz2 file will be created. The bzip2 utility does not change the modification data associated with the file, even though it completely changes the file contents.
Decompress / uncompressing a file using bunzip2 utility :
$bunzip2 filename.bz2
The bzcat utility displays a file that has been compressed with bzip2.
bzcat file_name.bz2 head -4
bzip2recover - supports limited data recovery from media errors.
RSS - Really simply syndication - Introduction And Uses:
RSS - Really simply syndication - A popular term among the blogger community.
What is RSS? What does it stand for?
RSS stands for "Really Simple Syndication".
Uses :
1) RSS is utilized by many blogs and websites
2) RSS is used to publish content using a document called as feed
What is a RSS feed? What does it contain?
A RSS feed is a summary of text from a participating website.. Information includes/ can be any of :
1) News
2) Podcasts
3) Information that is updated often
Google Search Story Video Creator, Create Own Free Search Story, Youtube Search Story Creator:
I found an interesting tool from Youtube (Google) a tool called as search story video creator (web application). Simply keyin search terms, this pulls results from google search, creates a video, uploads this to you tube upon confirmation. This is interesting and great tool. click on Create you own blue button. This takes us through the process. It is interesting to see that we can integrate music with our video. Variety of music scores have been recorded and can be added at the click of a mouse (shown in screen shot below)Create your Google/You Tube Search Story Today
Microsoft Hardware Blog:
Microsoft Hardware Blog is the official site from Microsoft corporation. This is the excerpt from Welcome Post in Microsoft Hardware Blog
"If you’re looking for a new product, or want to make the most out of the one you already have, then this is a great place for you.  We’re going to use this space to tell you about new mice, keyboards, webcams, headsets and gaming devices, keep you up-to-date on new software or product features, and give you insight into how we design our products for you that maybe you weren’t aware of.But the most important thing is that you can use this blog to give us feedback and ask us questions.  If you like something – tell us! If you don’t like something – tell us!
You’ll hear from a variety of people on this blog, and each of us look forward to telling you more about what we do, and hearing from you.
Again – welcome to the Microsoft Hardware Blog.
Brett Ostrum, General Manager"
Microsoft Hardware Blog http://microsofthardwareblog.com/
We can get latest hardware news and product updates from Microsoft Corporation. Webcams is the major product listed in Top Categories Section of Microsoft Hardware Blog
Rename Multiple Files In Windows 7, Renaming Multiple Files in Windows 7:
It is possible to rename multiple filenames at once in Windows 7
Click on one file and press arrows to select all the files to be renamed
Click on File Menu. Click Rename. One file (first selected file) gets highlighted. Change its name. This automatically changes all other filenames in sequence
Worth Of Websites, Flip your websites at its value, Website Valuation:
Website business has been growing at a great pace. Creating and flipping websites have become a good business. Most of us don't know how to calculate the worth of a website. We flip it based on the general concept that it is 2 times worth of average annual income. Say if we make $1000 on an average per year, then we can sell our website somewhere between $2000 to $3000.
I found an interesting tool which will tell us the worth of our website based on criteria such as alexa ranking, google rank etc. This interesting tool is names MyWebsiteWorth
Log onto mywebsiteworth tool which is a website.Type the URL and click on worth button to find the worth of your website
Enterprise Microblogging Microsoft Officetalk, Social Networking In enterprise Microsoft Officetalk, Microsoft Officetalk Twitter Enterprise Version:
Microsoft officetalk is the enterprise microblogging solution from Microsoft corporation. We all know that the most popular microblogging platform among world community is twitter which was launched on 2006. In the same way officetalk is aimed at microblogging among the business users within an organization.Social networking among the enterprise community is the core behind microsoft officetalk.More information on office talk can be seen at Microsoft officelabs
Google Operations Shutdown In China, Google Quits China,China Says Bye To Google, Google China Shutdownwww.google.cn screenshot, China Says Bid Adieu To Google:
Google had earlier announced that April 10,2010 will be their last working day in China. Its shutdown will affect the Google Engineers working in Beijing and Guangzhou. More than 300 google engineers will be affected due to this shutdown.
I've taken a screen shot of Google China Website www.google.cn as a remembrance. First is in chinese language. Next photo is an English Translation of www.google.cn website
SEO (Search Engine Optimization ) Starter Guide From Google:
Google the best and biggest search engine in the world has helped people grow their business online. The core ambition of any online enterpreuner would be to have a good pagerank in google. This helps them pull plenty of google traffic. This free traffic from google is called as Organic traffic. Studies on traffic trends, increasing traffic comes under SEO. SEO is crucial for any online business these days. Most of us wonder where do we start learning it. Google has published a starter guide on SEO that can be downloaded for free and utilized to improve our pagerank.
Internet Explorer 9 HTML5 Browser, IE9 HTML5 Browser, IE9 Download And Installation,Windows Internet Explorer Platform Preview does not support any operating system earlier than Windows Vista SP2:
An interesting information on IE9 is that it is a HTML5 compatible. Also it is designed based on standard web patterns. It helps HTML 5 applications run faster by taking control of the hardware through Windows (OS).
I tried downloading and installing in my old laptop which runs Windows XP Home Edition. I got the following error — “Windows Internet Explorer Platform Preview does not support any operating system earlier than Windows Vista SP2″
In the nextarticle, I’ll be discussing on steps I followed while installing IE 9 in Windows 7 OS (new laptop).
Installing WAMP (Windows Apache MySQL PHP) Server, WAMP Prerequisite For Installing CMS (Joomla) Learning PHP, Create Dynamic Database Driven Website With WAMP:
WAMP Server - Windows, Apache,MySQL,PHP is a package that is available for free. Joomla, the most popular content management system(CMS), needs WAMP Server as the prerequisite.
This articles describes step by step installation of WAMP Server. Various server versions get released periodically. Kindly refer documentation for WAMP server and Joomla version compatability. WAMP package can be used with Windows OS. For Linux, LAMP - Linux,Apache,MySQL,PHP is used.
What does WAMP stand for?
W - Windows OS - Operating system
A - apache - Web Server
M - MySQL - Database
P - PHP - Scripting language
Above mentioned packages can be downloaded seperately and installed. Version compatability with Joomla release needs to be done before downloading and installing above mentioned packages.Steps for installing WAMP Server is presented below:
1) Download WAMP Server by clicking on Download tab from :
http://www.wampserver.com/en/
2) Unzip and Run the executable
3) Accept the Agreement
4) C:wamp is the default installation location. If different browse and choose it
5) Click Install
6) Choose the default browser
7) If firewall is enabled, it might ask you to unblock ports. click on unblock and Finish
8) Launch the WAMP Server
9) Check if the server is up and running by typing:
http://localhost
(or)
http://localhost:80
You'll get an UI view of WAMP Server
10) The Server dial icon will appear in taskbar of Desktop
11) If services are not in started state, left click and start all services. The dial will be red, become yellow on partial service startup, become white on starting all services
12) Server becomes online
13) Check if the server is up and running by typing:
http://localhost
(or)
http://localhost:80
You'll get an UI view of WAMP Server. WAMP Server installation acts as prerequisite for installation of content management systems (CMS) such as Joomla
Beware Of New Facebook Virus, New Facebook Virus, McAfee Warns Of Facebook Virus, Facebook email virus:
This tuesday Macafee Malware and Research Communication director Dave Marcus has warned facebook users of the new facebook malware.
Many of us know that Facebook overtook google last week. Hackers have now targeted facebook users and created malware viruses to hack the users passwords and credentials. These spammers send an email mocking Facebook official emails with the message that passwords of their accounts have been reset and will urge them to click on a link to reset their login credentials. This malicious programs will then steal the user's passwords.
With about 400million people using Facebook on a daily basis, even if 1% of them turn out to be a victim of these hackers, then its a huge deal for them. So kindly be beware of this malicious email message.
If you get such emails kindly log onto www.facebook.com and check if your credential works. Simple delete this email.