creating a new user in mysql

Here we are creating user with name manish and password for manish is password;

Creating a user and force user to change password at first login for that PASSWORD EXPIRE is used.

Creating a user and expiring the password after 180 days, PASSWORD EXPIRE INTERVAL 180 DAY is used

Creating a user … Read more

Changing primary key of table

We have a table basic profile with following table structure

we don’t want to use it as primary key so first we removed its auto increment the we will remove it from primary key queries for these are

If you want to make primary key to some other column than we can … Read more

Alter table command to add foreign key

We have two tables company and location. First table manages company details and second table stores location detail of company. one company can span in multiple location. Initially we have created table for company and location as below.

checking the description of both table

Now We find that one company can … Read more

Drop foreign key constraints

Some times we have to drop the foreign key constraint that already exists, for that we have to first get the foreign key constraint name. To see detailed description of created table we use following query.

Result of above query is

Here we can see that company_id column is referring company tables id … Read more

Show engine innodb status

InnoDB Monitors provide information about the InnoDB internal state. This information is useful for performance tuning. Each Monitor can be enabled by creating a table with a special name, which causes InnoDB to write Monitor output periodically. Also, output for the standard InnoDB Monitor is available on demand through the SHOW ENGINE INNODB STATUS SQL … Read more

updating user login password

SET PASSWORD FOR ‘user’@’localhost’ = PASSWORD( ‘NewPassword’ ); SHOW VARIABLES LIKE ‘validate_password%’; # SET GLOBAL validate_password_length = 5; # SET GLOBAL validate_password_number_count = 0; # SET GLOBAL validate_password_mixed_case_count = 0; # SET GLOBAL validate_password_special_char_count = 0;

Updating the column data size

To create a table

after creating table we want to increase the size of description field from varchar(20) to varchar(100). for that we will use alter table command Syntax

Example

we can also decrease the size of column but it may cause the data loss. like

Insertion of a new record in a table

To insert a new record in a table we use Insert Query. Syntax: To insert all fields value in table we use following insert query

To insert all or selected fields value in table we use following insert query

We have created a table student as below

To insert record in above … Read more

MySql Update table column from another table colunm

Updating a table fields from another table columns we can user following syntax

There are two tables table1 and table2. Both table have common id value. To select appropriate field from table inner join in used and updating table1 fields from table2 fields set statement is used. For example there are two tables with … Read more

MySql Select Database

Suppose you have created database, to use it , write query: Syntax

If we want to select ebhor database then use following query

with the help of this query you can work on your created database.