How to create a backup or copy of a database ?
mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql
How to find duplicate entry or duplicate row in a table
Filed under: MySQL Interview Questions, Oracle Interview Questions, PostgreSQL Interview Questions, SQL SERVER Interview Questions
In this sql command we are trying to find the duplicate entry with duplicate name. This sql command will give all the MIN id which has duplicate entry
SELECT MIN(id) AS dupid,COUNT(name) AS dupcnt
FROM tablename
GROUP BY name HAVING dupcnt>1
It should work on Oracle, Mysql
How can you access MySQL function in PHP
Filed under: MySQL Interview Questions, PHP Interview Questions
MYSQL is not available as a default feature it must be created by the user. You can use –with-mysql=DIR function to make available SQL on your system. Compiling PHP functions with MYSQL will increase the support and functioning of the language. MYSQL should be installed where there are extensions of PHP
How to create user in MySql – MySQL Interview Questions
How to create user in mysql
SQL Command is below to create user in mysql . SQL Query to create user in mysql
CREATE USER ‘monty’@'localhost’ IDENTIFIED BY ‘some_pass’;
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘monty’@'localhost’
-> WITH GRANT OPTION;
mysql> CREATE USER ‘monty’@'%’ IDENTIFIED BY ‘some_pass’;
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘monty’@'%’
-> WITH GRANT OPTION;
mysql> CREATE USER ‘admin’@'localhost’;
mysql> GRANT RELOAD,PROCESS ON *.* TO ‘admin’@'localhost’;
mysql> CREATE USER ‘dummy’@'localhost’;
