WordPress interview question and answers

WordPress interview question and answers
5 (100%) 1 vote

1) What is WordPress?

Word press is a best Open Source CMS which allows it to be used free of cost.  You can use it on any kind of personal or commercial website without have to pay a single penny for it. It is built on PHP/MySQL (which is again Open Source) and licensed under GPL.

2) How safe is website on WordPress?

 The word press is safe to operate but still it is suggested to keep updating with the latest version of WordPress to avoid hacking.

3) Are there any limitations to a WordPress web site?

You can use WordPress for e-commerce sites, membership sites, photo galleries and any other type of site you can think of. The web site is created using the same html code as any other site so there are no limitations there either.

[ad name=”Video”]

4) Do you need to have a blog in order to use WordPress for site?

WordPress was originally used as blogging software though it has since become popular for website also.  It is not necessary to have a blog to use wordpress.  Still having blog is commendable as it will help in search engine optimization.

5) From SEO point of view is wordpress helpful? Will it show the website on Google?

 It is one of the benefit of using wordpress, it has inbuilt SEO search engine. Also, you can have an additional plug-in in wordpress to help with SEO and rank on a popular search engine like Google.

6) What is the current version of wordpress?

You need to quote the current version of WordPress available in market along with the release date.

7) What are the types of hooks in WordPress and mention their functions?

There are two types of hooks 1) Action hooks 2) Filter hooks

Hooks allow user to create WordPress theme or plugin with shortcode without changing the original files. Action hooks allow you to insert an additional code from an outside resource, whereas, Filter hooks will only allow you to add a content or text at the end of the post.

8) What do you mean by custom field in wordpress?

Custom field is a meta-data that allows you to store arbitrary information to the wordpress post. Through custom field extra information can be added to the post.

[ad name=”Video”]

9) What are the positive aspects of wordpress?

Few positive aspects of wordpress are

  • Easy installation and upgrade
  • In-built SEO engine
  • Easy theme system
  • Flexibility
  • Multilingual- available in more than 70 languages
  • Own data- no unwanted advert on your website
  • Flexibility and Easy publishing option

10) What are the rules that you have to follow for wordpress plugin development?

  • Create a unique name
  • Create the plugin’s folder
  • Create a sub-folder for PHP files,  translations and assets
  • Create the main plug-in file and fill in header information
  • Create activation and de-activation functions
  • Create an uninstall script
  • Create a readme.txt file
  • To detect paths to plugin file use proper constants and functions

11) What is the prefix of wordpress tables by default?

By default, wp_ is the prefix for wordpress.

12) Why does WordPress use MySQL?

MySQL is widely available database server and is extremely fast.  It is an open source and it is available at no cost also it is supported by many low-cost Linux hosts so its easy for anyone to host their website.

[ad name=”Video”]

13) Is it possible to rename the WordPress folder?

Yes, it is possible to rename the WordPress folder.  If WordPress is already installed you have to login to the weblog as the administrator and then change the settings

WordPress address (URI)  :

Blog address( URI) :

After making the changes, you can rename the folder or directory with the WordPress file in it.

14) How many tables are there in WordPress by default?

There are about 11 tables in WordPress by default. Note: With succeeding releases of WordPress this number will change. You need to check phpMyAdmin to determine the number of tables in a vanilla version of latest WordPress installation.

15) What is WordPress loop?

To display post WordPress use PHP code, this code is known as loop.

16) How you can disable the WordPress comment?

If you go on dashboard under options-discussion there is a comment “ Allow people to post comment” try unchecking the comment.

17) What are the steps you can take if your WordPress file is hacked?

  • Install security plug-ins like WP security
  • Re-install the latest version of WordPress
  • Change password and user-ids for all your users
  • Check your themes and plug-ins are up to date

18) What are the template tags in WordPress?

In WordPress template tags is a code that instructs WordPress to “do” or “get” something.

[ad name=”Video”]

19) Does WordPress have cookies?

Yes, WordPress have cookies and WordPress uses cookies for verification of users while logged in.

20) In what case you don’t see plugin menu?

You can’t see your plugin menu when the blog is hosted on free wordpress.com as you cannot add plugin there.  Also, if you do not have an account of an administrator level on your WordPress is not possible to see plugin.

21) At what instance you get locked out of your WordPress admin and see your website as a blank screen?

This would likely happen when you have pasted a code from a website with wrong formats, also when you have pasted a code in a wrong location. It may also happen when your IP is banned

22) Why you use a static front page in wordpress?

Some WordPress users wants their WordPress installation to be more than a blog site. To give their page a look more like a real website page some users use static front page.

23) What are the plugins you can use to create contact form in WordPress?

To create a contact form in WordPress you can use plugin like Gravity forms or also you can use a free plugin contact form 7.

24) Why widget does not show up in the sidebar?

While using widget you have to ensure whether your theme supports the widget and if it does then it must show the sidebar.  If in any case if it happens that you don’t see the sidebar then it might be missing the “function.php” file or file similar to that.  This can also happen if you have forgot to save the changes in the widget or refreshing the older display of the page.

[ad name=”Video”]

25) Is there any limitation for using WordPress?

No, there is no limitation for using WordPress.  WordPress can be used for innumerable purpose membership site, e-commerce site, photo-gallery and many more.

26) How is creating a site on wordpress.org different from wordpress.com?

Most of the things are similar in both except the choices of themes and the usage of plugins.

27) Why wordpress.com is considered more secure than wordpress.org?

WordPress.com is considered more secure than wordpress.org because they limit the themes and also does not allow installing plugin’s.  However the security is more dependable on how the hosting company is hosting your website(wordpress.org) & also what are the steps they are taking to prevent the security problems.

28) Does de-activated plugins slow down a WordPress site?

No, de-activated plugins cannot slow down the WordPress site.  Wordpress only loads the active plugins and ignores everything else.

[ad name=”Video”]

29) In what case we cannot recommend WordPress to our client?

We cannot recommend WordPress on following situation:

  • If client is working on non-CMS base project
  • If site wants complex or innovative e-commerce
  • In case of enterprise intranet solution
  • Sites requiring custom scripting solutions.

30) What are the essential features you look for a theme?

Theme selection differs according to the requirement, but an ideal theme would be something that would not restrict to use the number of pages, plugins or static homepage.

31) How Custom theme is different than Normal theme?

Custom theme allows for SEO search, but with a SEO plugin available it would not make much difference to normal theme. One benefit using the Custom theme is that it allows to make the changes without going much into the coding part.

32) How you can create a static page with WordPress?

To create a static page in wordpress, in the page section  you have to upload a php files to the server in the theme folder, and then select that as your template.  This allows you to add any page and look that you wanted for your blog and it will remain static.

33) Is there any other CMS better WordPress?

WordPress is no doubt a good CMS, but Drupal and Joomla are among the best CMS you can work with.

34) Which is the best multi-lingual plugin for wordpress?

Keeping all the limitations in mind, WPML would be the best multi-lingual plugin for wordpress .

[ad name=”Video”]

35) Can you update your own content on the site?

It depends on the type of the site or project, but yes one can update their own content on the site.

36) What are meta-tags?

Meta-tags are keywords and description used to display website or page information.

37) What should one use for plugin development — custom post types or custom database tables?

There is no specific preference for plugin development; it depends on what type of plugin’s one has to develop. Though few recommend custom post type, as it has few benefits comparison to custom database table.

38) Can you host WordPress using  Amazon web services such as EC2, RDS, EBS etc?

Yes, you can host using Amazon web services.

39) Is there any way to write series in WordPress?

You can use organize series plugin to write series in wordpress.

40) What are the reasons why one should not hack WordPress core file?

The best reason not to hack the core files is that whatever you might be doing has to be reworked as a patch.

The most frequent queries you can expect to be asked while going for the job interview. These questions are asked by many popular companies in the interview round to the candidates applying for the job of CMS developer or WordPress Developer. Many queries in this post are really tricky and can confuse even the professional developers so if you are going for the job interview then I highly recommends you to check these latest WordPress interview questions with answers 2015-2016.

  • What are the types of hooks in WordPress and mention their functions?

There are two types of hooks 1) Action hooks 2) Filter hooks

Hooks allow user to create WordPress theme or plugin with shortcode without changing the original files. Action hooks allow you to insert an additional code from an outside resource, whereas, Filter hooks will only allow you to add a content or text at the end of the post.

  • What are the rules that you have to follow for WordPress plugin development?

Create a unique name

Create the plugin’s folder

Create a sub-folder for PHP files, translations and assets

Create the main plug-in file and fill in header information

Create activation and de-activation functions

Create an uninstall script

Create a readme.txt file

To detect paths to plugin file use proper constants and functions

  • What is the prefix of WordPress tables by default?

By default, wp_ is the prefix for WordPress.

  • How many tables are there in WordPress by default?

There are about 11 tables in WordPress by default. Note: (Tested upto current WordPress version 4.2.4) you need to check phpMyAdmin to determine the number of tables in latest WordPress installation.

  • How you can disable the WordPress comment?

If you go on dashboard under options-discussion there is a comment “Allow people to post comment” try unchecking the comment.

  • Does de-activated plugins slow down a WordPress site?

No, de-activated plugins cannot slow down the WordPress site.  WordPress only loads the active plugins and ignores everything else.

  • Which is the best multi-lingual plugin for WordPress?

Keeping all the limitations in mind, WPML would be the best multi-lingual plugin for WordPress.

  • What is the basic difference between posts vs. Pages?

Posts and pages are the two content types used in WordPress. When WordPress is used as a blogging platform, majority of the content are posts. Posts are timed and are listed in chronological order with the latest posts on the top. The old posts are archived on the basis of month and year. Posts are meant to be shared and commented on.

Pages in WordPress, on the other hand, are static content that may include about us, contact us, privacy policies and others pages. The pages are timeless entries and do not have a date or month associated with them. For instance, even if you make changes to them, you will not have a Privacy policy page 2015 and Privacy policy page 2016 and so on. WordPress pages are not interactive and users do not share or comment on it.

[ad name=”Video”]

  • What is the difference between starting a string with single quote and double quote? What you will use in general instance?

A data kept inside a single quoted string is not parsed for variable substitution where as when we initialize the string with double quote the data is parsed for variable substitution. If we don’t require variable substitution particularly then it is always preferred to use single quote as it is much speedy process.

  • Who is founder of WordPress?

Matthew Charles Mullenweg.

  • How to hide the top admin bar at the frontend in WordPress?

Add following code in functions.php

add_filter(‘show_admin_bar’, ‘__return_false’);

  • How to run database Query in WordPress?

$wpdb->query(“select * from $wpdb->posts   where ID>10 “);

[ad name=”Video”]

  • What types of hooks in WordPress is used?

1) Following are Actions hooks:

has_action()

add_action()

do_action()

do_action_ref_array()

did_action()

remove_action()

remove_all_actions()

2) Following are Filters hooks:

has_filter()

add_filter()

apply_filters()

apply_filters_ref_array()

current_filter()

remove_filter()

remove_all_filters()

  • List most commonly functions used in WordPress?

wp_nav_menu() : Displays a navigation menu.

is_page() : to check if this is page OR NOT, will return Boolean value.

get_the_excerpt() : Copy the excerpt of the post into a specified variable.

in_category() : Check if the specified post is assigned to any of the specified categories OR not.

the_title(): Displays the title of the post in website.

the_content(): Displays the contents of the post in website.

  • What are the template tags in WordPress?

A template tag is code that instructs WordPress to “do” or “get” something. Like in header.php  we will use the tag bloginfo(‘name’) to get “Site Title” from wp-options table which is set in Setting > General at WordPress dashboard.

The the_title() template tag is used to display the post title.

wp_list_cats() is  for display categories.

get_header() for getting header.

get_sidebar() for display the sidebar on page.

get_footer() for display the footer content on page.

  • How to write the short code in WordPress php file?

Using do_shortcode() function inside of php tag. A very simple solution is to use the do_shortcode() function inside a PHP echo tag.

<?php do_shortcode(“[shortcode]”); ?>

Short code is used in WordPress post or page and text box widget and php file.

  • What is the difference between the wp_title and the_title tags?

wp_title() function is for use outside “The Loop” to display the title of a Page.  the_title() on the other hand is used within “The Loop“.

You are welcome to raise any query related to the interview process in the comment box. More over I also recommend you to check the Creative Resume Samples to impress the interview panel. Wish you best of luck for your interview.

[ad name=”Video”]

That’s all for today. Signing Off

Welcome !!!. In this section we are providing you some frequently asked PHP Interview Questions which will help you to win interview session easily. Candidates must read this section,Then by heart the questions and answers. Also, review sample answers and advice on how to answer these typical interview questions. PHP is an important part of the web world, and every web developer should have the basic knowledge in PHP.Common PHP interview questions, which should help you become a best PHP codder. We hope you find these questions useful. If you are an interviewer, Take the time to read the common interview questions you will most likely be asked.

  • Download Pdf
  • Job interview question
  • Questions and answers
  • Apache virtual hosts
  • Advice chat rooms free
  • Attributes
  • Car Insurances
  • Echos
  • Explode
  • File Paths
  1. What is PHP?

PHP is a server side scripting language commonly used for web applications. PHP has many frameworks and cms for creating websites.Even a non technical person can cretae sites using its CMS.WordPress,osCommerce are the famus CMS of php.It is also an object oriented programming language like java,C-sharp etc.It is very eazy for learning

  1. What is the use of “echo” in php?

It is used to print a data in the webpage, Example: <?php echo ‘Car insurance’; ?> , The following code print the text in the webpage

  1. How to include a file to a php page?

We can include a file using “include() ” or “require()” function with file path as its parameter.

  1. What’s the difference between include and require?

If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.

  1. require_once(), require(), include().What is difference between them?

require() includes and evaluates a specific file, while require_once() does that only if it has not been included before (on the same page). So, require_once() is recommended to use when you want to include a file where you have a lot of functions for example. This way you make sure you don’t include the file more times and you will not get the “function re-declared” error.

  1. Differences between GET and POST methods ?

We can send 1024 bytes using GET method but POST method can transfer large amount of data and POST is the secure method than GET method .

  1. How to declare an array in php?

Eg : var $arr = array(‘apple’, ‘grape’, ‘lemon’);

  1. What is the use of ‘print’ in php?

This is not actually a real function, It is a language construct. So you can use with out parentheses with its argument list.
Example print(‘PHP Interview questions’);
print ‘Job Interview ‘);

  1. What is use of in_array() function in php ?

in_array used to checks if a value exists in an array

  1. What is use of count() function in php ?

count() is used to count all elements in an array, or something in an object

  1. What’s the difference between include and require?

It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.

[ad name=”Video”]

  1. What is the difference between Session and Cookie?

The main difference between sessions and cookies is that sessions are stored on the server, and cookies are stored on the user’s computers in the text file format. Cookies can not hold multiple variables,But Session can hold multiple variables.We can set expiry for a cookie,The session only remains active as long as the browser is open.Users do not have access to the data you stored in Session,Since it is stored in the server.Session is mainly used for login/logout purpose while cookies using for user activity tracking

  1. How to set cookies in PHP?

Setcookie(“sample”, “ram”, time()+3600);

  1. How to Retrieve a Cookie Value?

eg : echo $_COOKIE[“user”];

  1. How to create a session? How to set a value in session ? How to Remove data from a session?

Create session : session_start();
Set value into session : $_SESSION[‘USER_ID’]=1;
Remove data from a session : unset($_SESSION[‘USER_ID’];

  1. what types of loops exist in php?

for,while,do while and foreach (NB: You should learn its usage)

  1. How to create a mysql connection?

mysql_connect(servername,username,password);

  1. How to select a database?

mysql_select_db($db_name);

  1. How to execute an sql query? How to fetch its result ?

$my_qry = mysql_query(“SELECT * FROM users WHERE u_id=’1′; “);
$result = mysql_fetch_array($my_qry);
echo $result[‘First_name’];

[ad name=”Video”]

  1. Write a program using while loop

$my_qry = mysql_query(“SELECT * FROM users WHERE u_id=’1′; “);
while($result = mysql_fetch_array($my_qry))
{
echo $result[‘First_name’.].”<br/>”;
}

  1. How we can retrieve the data in the result set of MySQL using PHP?
    • 1. mysql_fetch_row
    • 2. mysql_fetch_array
    • 3. mysql_fetch_object
    • 4. mysql_fetch_assoc
  2. What is the use of explode() function ?

Syntax : array explode ( string $delimiter , string $string [, int $limit ] );
This function breaks a string into an array. Each of the array elements is a substring of string formed by splitting it on boundaries formed by the string delimiter.

[ad name=”Video”]

  1. What is the difference between explode() and split() functions?

Split function splits string into array by regular expression. Explode splits a string into array by string.

  1. What is the use of mysql_real_escape_string() function?

It is used to escapes special characters in a string for use in an SQL statement

  1. Write down the code for save an uploaded file in php.

if ($_FILES[“file”][“error”] == 0)
{
move_uploaded_file($_FILES[“file”][“tmp_name”],
“upload/” . $_FILES[“file”][“name”]);
echo “Stored in: ” . “upload/” . $_FILES[“file”][“name”];
}

  1. How to create a text file in php?

$filename = “/home/user/guest/newfile.txt”;
$file = fopen( $filename, “w” );
if( $file == false )
{
echo ( “Error in opening new file” ); exit();
}
fwrite( $file, “This is a simple test\n” );
fclose( $file );

[ad name=”Video”]

  1. How to strip whitespace (or other characters) from the beginning and end of a string ?

The trim() function removes whitespaces or other predefined characters from both sides of a string.

  1. What is the use of header() function in php ?

The header() function sends a raw HTTP header to a client browser.Remember that this function must be called before sending the actual out put.For example, You do not print any HTML element before using this function.

  1. How to redirect a page in php?

The following code can be used for it, header(“Location:index.php”);

  1. How stop the execution of a php scrip ?

exit() function is used to stop the execution of a page

  1. How to set a page as a home page in a php based site ?

index.php is the default name of the home page in php based sites

  1. How to find the length of a string?

strlen() function used to find the length of a string

  1. what is the use of rand() in php?

It is used to generate random numbers.If called without the arguments it returns a pseudo-random integer between 0 and getrandmax(). If you want a random number between 6 and 12 (inclusive), for example, use rand(6, 12).This function does not generate cryptographically safe values, and should not be used for cryptographic uses. If you want a cryptographically secure value, consider using openssl_random_pseudo_bytes() instead.

  1. what is the use of isset() in php?

This function is used to determine if a variable is set and is not NULL

  1. What is the difference between mysql_fetch_array() and mysql_fetch_assoc() ?

mysql_fetch_assoc function Fetch a result row as an associative array, While mysql_fetch_array() fetches an associative array, a numeric array, or both

[ad name=”Video”]

  1. What is mean by an associative array?

Associative arrays are arrays that use string keys is called associative arrays.

  1. What is the importance of “method” attribute in a html form?

“method” attribute determines how to send the form-data into the server.There are two methods, get and post. The default method is get.This sends the form information by appending it on the URL.Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.

  1. What is the importance of “action” attribute in a html form?

The action attribute determines where to send the form-data in the form submission.

  1. What is the use of “enctype” attribute in a html form?

The enctype attribute determines how the form-data should be encoded when submitting it to the server. We need to set enctype as “multipart/form-data” when we are using a form for uploading files

  1. How to create an array of a group of items inside an HTML form ?

We can create input fields with same name for “name” attribute with squire bracket at the end of the name of the name attribute, It passes data as an array to PHP.
For instance :

<input name=”MyArray[]” />  <input name=”MyArray[]” />  <input name=”MyArray[]” />  <input name=”MyArray[]” />

  1. Define Object-Oriented Methodology

Object orientation is a software/Web development methodology that is based on the modeling a real world system.An object is the core concept involved in the object orientation. An object is the copy of the real world enity.An object oriented model is a collection of objects and its inter-relationships

  1. How do you define a constant?

Using define() directive, like define (“MYCONSTANT”,150)

  1. How send email using php?

To send email using PHP, you use the mail() function.This mail() function accepts 5 parameters as follows (the last 2 are optional). You need webserver, you can’t send email from localhost. eg : mail($to,$subject,$message,$headers);

  1. How to find current date and time?

The date() function provides you with a means of retrieving the current date and time, applying the format integer parameters indicated in your script to the timestamp provided or the current local time if no timestamp is given. In simplified terms, passing a time parameter is optional – if you don’t, the current timestamp will be used.

  1. Difference between mysql_connect and mysql_pconnect?

There is a good page in the php manual on the subject, in short mysql_pconnect() makes a persistent connection to the database which means a SQL link that do not close when the execution of your script ends. mysql_connect()provides only for the databasenewconnection while using mysql_pconnect , the function would first try to find a (persistent) link that’s already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection… the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use.

[ad name=”Video”]

  1. What is the use of “ksort” in php?

It is used for sort an array by key in reverse order.

  1. What is the difference between $var and $$var?

They are both variables. But $var is a variable with a fixed name. $$var is a variable who’s name is stored in $var. For example, if $var contains “message”, $$var is the same as $message.

  1. What are the encryption techniques in PHP

MD5 PHP implements the MD5 hash algorithm using the md5 function,
eg : $encrypted_text = md5 ($msg);

mcrypt_encrypt :- string mcrypt_encrypt ( string $cipher , string $key , string $data , string $mode [, string $iv ] );
Encrypts plaintext with given parameters

  1. What is the use of the function htmlentities?

htmlentities Convert all applicable characters to HTML entities This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.

[ad name=”Video”]

  1. How to delete a file from the system

Unlink() deletes the given file from the file system.

  1. How to get the value of current session id?

session_id() function returns the session id for the current session.

  1. What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?
    • Mysql_fetch_array Fetch a result row as an associative array, a numeric array, or both.
    • mysql_fetch_object ( resource result ) Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows
    • mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.
  2. What are the different types of errors in PHP ?

Here are three basic types of runtime errors in PHP:

    • 1. Notices: These are trivial, non-critical errors that PHP encounters while executing a script – for example, accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all – although you can change this default behavior.
    • 2. Warnings: These are more serious errors – for example, attempting to include() a file which does not exist. By default, these errors are displayed to the user, but they do not result in script termination.
    • 3. Fatal errors: These are critical errors – for example, instantiating an object of a non-existent class, or calling a non-existent function. These errors cause the immediate termination of the script, and PHP’s default behavior is to display them to the user when they take place.
  1. what is sql injection ?

SQL injection is a malicious code injection technique.It exploiting SQL vulnerabilities in Web applications

  1. What is x+ mode in fopen() used for?

Read/Write. Creates a new file. Returns FALSE and an error if file already exists

  1. How to find the position of the first occurrence of a substring in a string

strpos() is used to find the position of the first occurrence of a substring in a string

  1. What is PEAR?

PEAR is a framework and distribution system for reusable PHP components.The project seeks to provide a structured library of code, maintain a system for distributing code and for managing code packages, and promote a standard coding style.PEAR is broken into three classes: PEAR Core Components, PEAR Packages, and PECL Packages. The Core Components include the base classes of PEAR and PEAR_Error, along with database, HTTP, logging, and e-mailing functions. The PEAR Packages include functionality providing for authentication, networking, and file system features, as well as tools for working with XML and HTML templates.

  1. Distinguish between urlencode and urldecode?

This method is best when encode a string to used in a query part of a url. it returns a string in which all non-alphanumeric characters except -_. have replece with a percentege(%) sign . the urldecode->Decodes url to encode string as any %and other symbole are decode by the use of the urldecode() function.

  1. What are the different errors in PHP?

In PHP, there are three types of runtime errors, they are:

Warnings:
These are important errors. Example: When we try to include () file which is not available. These errors are showed to the user by default but they will not result in ending the script.
Notices:
These errors are non-critical and trivial errors that come across while executing the script in PHP. Example: trying to gain access the variable which is not defined. These errors are not showed to the users by default even if the default behavior is changed.
Fatal errors:
These are critical errors. Example: instantiating an object of a class which does not exist or a non-existent function is called. These errors results in termination of the script immediately and default behavior of PHP is shown to them when they take place. Twelve different error types are used to represent these variations internally.

  1. How would you check if MySql service is running or not?

Answer : Issue the command “service mysql status” in ‘Debian’ and “service mysqld status” in RedHat. Check the output, and all done.

[email protected]:/home/avi# service mysql status

[ad name=”Video”]

/usr/bin/mysqladmin  Ver 8.42 Distrib 5.1.72, for debian-linux-gnu on i486

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Server version 5.1.72-2

Protocol version 10

Connection Localhost via UNIX socket

UNIX socket /var/run/mysqld/mysqld.sock

Uptime: 1 hour 22 min 49 sec

[ad name=”Video”]

Threads: 1  Questions: 112138  Slow queries: 1  Opens: 1485  Flush tables: 1  Open tables: 64  Queries per second avg: 22.567.

  1. If the service is running/stop how would you stop/start the service?

Answer : To start MySql service use command as service mysqld start and to stop use service mysqld stop.

[email protected]:/home/avi# service mysql stop

Stopping MySQL database server: mysqld.

[email protected]:/home/avi# service mysql start

Starting MySQL database server: mysqld.

[ad name=”Video”]

Checking for corrupt, not cleanly closed and upgrade needing tables..

  1. How will you login to MySQL from Linux Shell?

Answer : To connect or login to MySQL service, use command: mysql -u root -p.

[email protected]:/home/avi# mysql -u root -p

Enter password:

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

Your MySQL connection id is 207

Server version: 5.1.72-2 (Debian)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

[ad name=”Video”]

mysql>

  1. How will you obtain list of all the databases?

Answer : To list all currently running databases run the command on mysql shell as: show databases;

mysql> show databases;

+——————–+

| Database           |

+——————–+

| information_schema |

| a1                 |

| cloud              |

| mysql              |

| phpmyadmin         |

| playsms            |

| sisso              |

| test               |

| ukolovnik          |

| wordpress          |

+——————–+

10 rows in set (0.14 sec)

  1. How will you switch to a database, and start working on that?

Answer : To use or switch to a specific database run the command on mysql shell as: use database_name;

mysql> use cloud;

Reading table information for completion of table and column names

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

[ad name=”Video”]

Database changed

mysql>

  1. How will you get the list of all the tables, in a database?

Answer : To list all the tables of a database use the command on mysql shell as: show tables;

mysql> show tables;

+—————————-+

| Tables_in_cloud            |

+—————————-+

| oc_appconfig               |

| oc_calendar_calendars      |

| oc_calendar_objects        |

| oc_calendar_repeat         |

| oc_calendar_share_calendar |

| oc_calendar_share_event    |

| oc_contacts_addressbooks   |

| oc_contacts_cards          |

| oc_fscache                 |

| oc_gallery_sharing         |

+—————————-+

10 rows in set (0.00 sec)

  1. How will you get the Field Name and Type of a MySql table?

Answer : To get the Field Name and Type of a table use the command on mysql shell as: describe table_name;

mysql> describe oc_users;

+———-+————–+——+—–+———+——-+

| Field    | Type         | Null | Key | Default | Extra |

+———-+————–+——+—–+———+——-+

| uid      | varchar(64)  | NO   | PRI |         |       |

| password | varchar(255) | NO   |     |         |       |

+———-+————–+——+—–+———+——-+

2 rows in set (0.00 sec)

  1. How will you delete a table?

Answer : To delte a specific table use the command on mysql shell as: drop table table_name;

mysql> drop table lookup;

Query OK, 0 rows affected (0.00 sec)

  1. What about database? How will you delete a database?

Answer : To delte a specific database use the command on mysql shell as: drop database database-name;

mysql> drop database a1;

Query OK, 11 rows affected (0.07 sec)

[ad name=”Video”]

  1. How will you see all the contents of a table?

Answer : To view all the contents of a particular table use the command on mysql shell as: select * from table_name;

mysql> select * from engines;

+————+———+—————————————————————-+————–+——+————+

| ENGINE     | SUPPORT | COMMENT                                                        | TRANSACTIONS | XA   | SAVEPOINTS |

+————+———+—————————————————————-+————–+——+————+

| InnoDB     | YES     | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |

| MRG_MYISAM | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |

| BLACKHOLE  | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |

| CSV        | YES     | CSV storage engine                                             | NO           | NO   | NO         |

| MEMORY     | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |

| FEDERATED  | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |

| ARCHIVE    | YES     | Archive storage engine                                         | NO           | NO   | NO         |

| MyISAM     | DEFAULT | Default engine as of MySQL 3.23 with great performance         | NO           | NO   | NO         |

+————+———+—————————————————————-+————–+——+————+

8 rows in set (0.00 sec)

  1. How will you see all the data in a field (say, uid), from table (say, oc_users)?

Answer : To view all the data in a field use the command on mysql shell as: select uid from oc_users;

mysql> select uid from oc_users;

+—–+

| uid |

+—–+

| avi |

+—–+

1 row in set (0.03 sec)

  1. Say you have a table ‘xyz’, which contains several fields including ‘create_time’ and ‘engine’. The field ‘engine’ is populated with two types of data ‘Memory’ and ‘MyIsam’. How will you get only ‘create_time’ and ‘engine’ from the table where engine is ‘MyIsam’?

Answer : Use the command on mysql shell as: select create_time, engine from xyz where engine=”MyIsam”;

  1. mysql> select create_time, engine from xyz where engine=”MyIsam”;

+———————+——–+

| create_time         | engine |

+———————+——–+

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-12-15 13:43:27 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

| 2013-10-23 14:56:38 | MyISAM |

+———————+——–+

132 rows in set (0.29 sec)

  1. How will you show all the records from table ‘xrt’ where name is ‘tecmint’ and web_address is ‘tecmint.com’?

Answer : Use the command on mysql shell as: select * from xrt where name = “tecmint” and web_address = “tecmint.com”;

mysql> select  * from xrt where name = “tecmint” and web_address = “tecmint.com”;

+—————+———————+—————+

| Id                  | name                   | web_address |

+—————+———————+—————-+

| 13                 |  tecmint               | tecmint.com  |

+—————+———————+—————-+

| 41                 |  tecmint               | tecmint.com  |

+—————+———————+—————-+

  1. How will you show all the records from table ‘xrt’ where name is not ‘tecmint’ and web_address is ‘tecmint.com’?

Answer : Use the command on mysql shell as: select * from xrt where name != “tecmint” and web_address = “tecmint.com”;

mysql> select * from xrt where name != ”tecmint” and web_address = ”tecmint.com”;

+—————+———————+—————+

| Id            | name                | web_address   |

+—————+———————+—————-+

| 1173          |  tecmint            | tecmint.com   |

+—————+———————+—————-+

  1. You need to know total number of row entry in a table. How will you achieve it?

Answer : Use the command on mysql shell as: select count(*) from table_name;

mysql> select count(*) from Tables;

+———-+

| count(*) |

+———-+

|      282 |

+———-+

1 row in set (0.01 sec)

 

Please follow and like us:
0

0 Comments

Leave your comment