SlideShare une entreprise Scribd logo
1  sur  76
MYSQL
[object Object],[object Object],[object Object],[object Object],What is MYSQL?
INSTALLATOIN, CONFIGURATION & COMMANDS -BY H. ANKUSH. JAIN
INSTALLATION & CONFIGURATION
download the latest MySQL install package from the MySQL site. I recommend you use the Windows Essentials package. ,[object Object]
Step 1: Choose the setup type ,[object Object],[object Object]
Step 2 ,[object Object],[object Object]
Step 3 ,[object Object],[object Object]
Step 4 ,[object Object],[object Object]
Step 5: Configuring MySQL ,[object Object],[object Object]
Step 6 ,[object Object],[object Object]
Step 7 ,[object Object],[object Object]
Step 8 ,[object Object],[object Object]
Step 9 ,[object Object],[object Object],[object Object]
Step 10 ,[object Object],[object Object],[object Object]
Step 11 ,[object Object],[object Object],[object Object]
Step 12 ,[object Object],[object Object]
Step 13 ,[object Object],[object Object]
Step 14 ,[object Object],[object Object],[object Object]
Step 15 ,[object Object],[object Object],[object Object]
COMMANDS
Login to MySQL monitor ..ysqlinysql -u[username] -p[password] Example: ..ysqlinysql -uroot -pmysecret
Create a database on the sql server. SYNTAX: CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name [create_specification] ... create_specification: [DEFAULT] CHARACTER SET [=] charset_name | [DEFAULT] COLLATE [=] collation_name u-1@srv-1 mysqlart $ mysql -u root Welcome to the MySQL monitor.  Commands end with ; or . Your MySQL connection id is 5 to server version: 4.0.14-log Type 'help;' or '' for help. Type '' to clear the buffer. mysql> create database sysops; Query OK, 1 row affected (0.00 sec) mysql> quit Bye u-1@srv-1 mysqlart $  Example:
List all databases on the sql server. SYNTAX: mysql> show databases; mysql> SHOW DATABASES; +----------+ | Database | +----------+ | info     | | java2s   | | mysql    | | t        | | test     | | ttt      | +----------+ 6 rows in set (0.00 sec)
Switch to a database. mysql> use [db name];
To see all the tables in the db. mysql> show tables;
CREATE TABLE SYNTAX: CREATE TABLE [table_name] ( [column_name1] INT AUTO_INCREMENT, [column_name2] VARCHAR(30) NOT NULL, [column_name3] ENUM('guest', 'customer', 'admin')NULL, [column_name4] DATE NULL, [column_name5] VARCHAR(30) NOT NULL, [column_name6] DATETIME NOT NULL, [column_name7] CHAR(1) NULL, [column_name8] BLOB NULL, [column_name9] TEXT NOT NULL, UNIQUE(username), PRIMARY KEY (column_name1) ); Example: CREATE TABLE user ( userid INT AUTO_INCREMENT, username VARCHAR(30) NOT NULL, group_type ENUM('guest', 'customer', 'admin') NULL, date_of_birth DATE NULL, password VARCHAR(30) NOT NULL, registration_date DATETIME NOT NULL, account_disable CHAR(1) NULL, image BLOB NULL, comment TEXT NOT NULL, UNIQUE(username), PRIMARY KEY (userid) );
INSERT STATEMENTS ,[object Object],[object Object],[object Object],[object Object]
REPLACE STATEMENTS ,[object Object],[object Object],[object Object],[object Object]
UPDATE STATEMENTS  ,[object Object],[object Object],[object Object],[object Object]
Add a new column "male" in table user. Syntax: ALTER TABLE [table_name] ADD COLUMN [column_name] CHAR(1) NOT NULL; ,[object Object],[object Object],[object Object],[object Object]
Change column name "male" into "gender" in table user and change the type to VARCHAR(3) and allow NULL values. Syntax: ALTER TABLE [table_name] CHANGE [old_column] [new_column] VARCHAR(3) NULL; Example: ALTER TABLE user CHANGE male gender VARCHAR (3) NULL;
Change the size of column "gender" from 3 to 6 in table user. Syntax: ALTER TABLE [table_name] MODIFY [column_name] VARCHAR(6); Example: ALTER TABLE user MODIFY gender VARCHAR(6);
SELECT STATEMENTS ,[object Object],[object Object],[object Object],[object Object]
DELETE STATEMENTS ,[object Object],[object Object],[object Object],[object Object]
Show field formats of the selected table. Syntax: DESCRIBE [table_name]; Example: DESCRIBE mos_menu;
To see database's field formats. mysql> describe [table name];
To delete a db. mysql> drop database [database name]; Example: DROP DATABASE demodb;
To delete a table. mysql> drop table [table name]; Example: DROP TABLE user;
Show all data in a table. mysql> SELECT * FROM [table name]; Example: SELECT * FROM mos_menu;
Show all records from mos_menu table containing name "Home". SELECT * FROM [table_name] WHERE [field_name]=[value]; Example: SELECT * FROM mos_menu WHERE name = "Home";
Returns the columns and column information pertaining to the designated table. mysql> show columns from [table name];
Show certain selected rows with the value "whatever". mysql> SELECT * FROM [table name] WHERE [field name] = "whatever";
Show all records containing the name "Bob" AND the phone number '3444444'. mysql> SELECT * FROM [table name] WHERE name = "Bob" AND phone_number = '3444444';
Show all records not containing the name "Bob" AND the phone number '3444444' order by the phone_number field. mysql> SELECT * FROM [table name] WHERE name != "Bob" AND phone_number = '3444444' order by phone_number;
Show all records starting with the letters 'bob' AND the phone number '3444444'. mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444';
Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5. mysql> SELECT * FROM [table name] WHERE name like "Bob%" AND phone_number = '3444444' limit 1,5;
Use a regular expression to find records. Use "REGEXP BINARY" to force case-sensitivity. This finds any record beginning with a. mysql> SELECT * FROM [table name] WHERE rec RLIKE "^a";
Show unique records. mysql> SELECT DISTINCT [column name] FROM [table name];
Show selected records sorted in an ascending (asc) or descending (desc). mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;
Return number of rows. mysql> SELECT COUNT(*) FROM [table name];
Sum column. mysql> SELECT SUM(*) FROM [table name];
Join tables on common columns. mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;
Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs. # mysql -u root -p mysql> use mysql; mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password')); mysql> flush privileges;
Change a users password from unix shell. # [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'
Change a users password from MySQL prompt. Login as root. Set the password. Update privs. # mysql -u root -p mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere'); mysql> flush privileges;
Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server. # /etc/init.d/mysql stop # mysqld_safe --skip-grant-tables & # mysql -u root mysql> use mysql; mysql> update user set password=PASSWORD("newrootpassword") where User='root'; mysql> flush privileges; mysql> quit # /etc/init.d/mysql stop # /etc/init.d/mysql start
Set a root password if there is on root password. # mysqladmin -u root password newpassword
Update a root password. # mysqladmin -u root -p oldpassword newpassword
Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs. # mysql -u root -p mysql> use mysql; mysql> grant usage on *.* to bob@localhost identified by 'passwd'; mysql> flush privileges;
Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs. # mysql -u root -p mysql> use mysql; mysql> INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N'); mysql> flush privileges; or mysql> grant all privileges on databasename.* to username@localhost; mysql> flush privileges;
To update info already in a table. mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';
Delete a row(s) from a table. mysql> DELETE from [table name] where [field name] = 'whatever';
Update database permissions/privilages. mysql> flush privileges;
Delete a column. mysql> alter table [table name] drop column [column name];
Add a new column to db. mysql> alter table [table name] add column [new column name] varchar (20);
Change column name. mysql> alter table [table name] change [old column name] [new column name] varchar (50);
Make a unique column so you get no dupes. mysql> alter table [table name] add unique ([column name]);
Make a column bigger. mysql> alter table [table name] modify [column name] VARCHAR(3);
Delete unique from table. mysql> alter table [table name] drop index [colmn name];
Load a CSV file into a table. mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '' (field1,field2,field3);
Dump all databases for backup. Backup file is sql commands to recreate all db's. # [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql
Dump one database for backup. # [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql
Dump a table from a database. # [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql
Restore database (or database table) from backup. # [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql
Thank You

Contenu connexe

Tendances

Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL ISankhya_Analytics
 
Sql a practical introduction
Sql   a practical introductionSql   a practical introduction
Sql a practical introductionHasan Kata
 
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...Edureka!
 
Sql queries questions and answers
Sql queries questions and answersSql queries questions and answers
Sql queries questions and answersMichael Belete
 
Including Constraints -Oracle Data base
Including Constraints -Oracle Data base Including Constraints -Oracle Data base
Including Constraints -Oracle Data base Salman Memon
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentationNITISH KUMAR
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Punjab University
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Beat Signer
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)Syed Hassan Ali
 

Tendances (20)

Getting Started with MySQL I
Getting Started with MySQL IGetting Started with MySQL I
Getting Started with MySQL I
 
Sql a practical introduction
Sql   a practical introductionSql   a practical introduction
Sql a practical introduction
 
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
MySQL Tutorial For Beginners | Relational Database Management System | MySQL ...
 
SQL commands
SQL commandsSQL commands
SQL commands
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
MySQL for beginners
MySQL for beginnersMySQL for beginners
MySQL for beginners
 
Sql queries questions and answers
Sql queries questions and answersSql queries questions and answers
Sql queries questions and answers
 
Including Constraints -Oracle Data base
Including Constraints -Oracle Data base Including Constraints -Oracle Data base
Including Constraints -Oracle Data base
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
Sql queries presentation
Sql queries presentationSql queries presentation
Sql queries presentation
 
Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)Presentation slides of Sequence Query Language (SQL)
Presentation slides of Sequence Query Language (SQL)
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
 
Structured Query Language (SQL)
Structured Query Language (SQL)Structured Query Language (SQL)
Structured Query Language (SQL)
 
Introduction to Mysql
Introduction to MysqlIntroduction to Mysql
Introduction to Mysql
 

En vedette

Types of databases
Types of databasesTypes of databases
Types of databasesPAQUIAAIZEL
 
Congratsyourthedbatoo
CongratsyourthedbatooCongratsyourthedbatoo
CongratsyourthedbatooDave Stokes
 
Introduction To Navicat MySql GUI
Introduction To Navicat MySql GUIIntroduction To Navicat MySql GUI
Introduction To Navicat MySql GUIchadrobertson75
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinhwebhostingguy
 
The care and feeding of a MySQL database
The care and feeding of a MySQL databaseThe care and feeding of a MySQL database
The care and feeding of a MySQL databaseDave Stokes
 
DATABASE PROJECT
DATABASE PROJECTDATABASE PROJECT
DATABASE PROJECTabdul basit
 
Introducing the MySQL Workbench CASE tool
Introducing the MySQL Workbench CASE toolIntroducing the MySQL Workbench CASE tool
Introducing the MySQL Workbench CASE toolAndrás Bögöly
 
MN691 Assignment 3 - Final Report 2
MN691 Assignment 3 - Final Report 2MN691 Assignment 3 - Final Report 2
MN691 Assignment 3 - Final Report 2Abi Reddy
 
Recipe Database Project Management
Recipe Database Project ManagementRecipe Database Project Management
Recipe Database Project Managementformalforker
 
Grocery Station- Database Management System Project
Grocery Station- Database Management System ProjectGrocery Station- Database Management System Project
Grocery Station- Database Management System ProjectTapan Desai
 
SQL Server database project ideas - Top, latest and best project ideas final ...
SQL Server database project ideas - Top, latest and best project ideas final ...SQL Server database project ideas - Top, latest and best project ideas final ...
SQL Server database project ideas - Top, latest and best project ideas final ...Team Codingparks
 
MySQL Best Practices - OTN
MySQL Best Practices - OTNMySQL Best Practices - OTN
MySQL Best Practices - OTNRonald Bradford
 

En vedette (20)

Types of databases
Types of databasesTypes of databases
Types of databases
 
Dbms slides
Dbms slidesDbms slides
Dbms slides
 
Sql
SqlSql
Sql
 
EC Database System
EC Database SystemEC Database System
EC Database System
 
Congratsyourthedbatoo
CongratsyourthedbatooCongratsyourthedbatoo
Congratsyourthedbatoo
 
Introduction To Navicat MySql GUI
Introduction To Navicat MySql GUIIntroduction To Navicat MySql GUI
Introduction To Navicat MySql GUI
 
Mysql grand
Mysql grandMysql grand
Mysql grand
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinh
 
The care and feeding of a MySQL database
The care and feeding of a MySQL databaseThe care and feeding of a MySQL database
The care and feeding of a MySQL database
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
DATABASE PROJECT
DATABASE PROJECTDATABASE PROJECT
DATABASE PROJECT
 
Introducing the MySQL Workbench CASE tool
Introducing the MySQL Workbench CASE toolIntroducing the MySQL Workbench CASE tool
Introducing the MySQL Workbench CASE tool
 
MN691 Assignment 3 - Final Report 2
MN691 Assignment 3 - Final Report 2MN691 Assignment 3 - Final Report 2
MN691 Assignment 3 - Final Report 2
 
Mysql workbench 5
Mysql workbench 5Mysql workbench 5
Mysql workbench 5
 
Recipe Database Project Management
Recipe Database Project ManagementRecipe Database Project Management
Recipe Database Project Management
 
Fitness center
Fitness centerFitness center
Fitness center
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
Grocery Station- Database Management System Project
Grocery Station- Database Management System ProjectGrocery Station- Database Management System Project
Grocery Station- Database Management System Project
 
SQL Server database project ideas - Top, latest and best project ideas final ...
SQL Server database project ideas - Top, latest and best project ideas final ...SQL Server database project ideas - Top, latest and best project ideas final ...
SQL Server database project ideas - Top, latest and best project ideas final ...
 
MySQL Best Practices - OTN
MySQL Best Practices - OTNMySQL Best Practices - OTN
MySQL Best Practices - OTN
 

Similaire à MYSQL (20)

My sql presentation
My sql presentationMy sql presentation
My sql presentation
 
Sah
SahSah
Sah
 
MYSQL
MYSQLMYSQL
MYSQL
 
My sql.ppt
My sql.pptMy sql.ppt
My sql.ppt
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Diva10
Diva10Diva10
Diva10
 
My sql with querys
My sql with querysMy sql with querys
My sql with querys
 
mysqlHiep.ppt
mysqlHiep.pptmysqlHiep.ppt
mysqlHiep.ppt
 
Mysql
MysqlMysql
Mysql
 
Using Mysql.pptx
Using Mysql.pptxUsing Mysql.pptx
Using Mysql.pptx
 
Raj mysql
Raj mysqlRaj mysql
Raj mysql
 
My sql Syntax
My sql SyntaxMy sql Syntax
My sql Syntax
 
Sql Injection
Sql Injection Sql Injection
Sql Injection
 
MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
 
database-querry-student-note
database-querry-student-notedatabase-querry-student-note
database-querry-student-note
 
Msql
Msql Msql
Msql
 
My sql
My sqlMy sql
My sql
 
Web Developement Workshop (Oct 2009) Slides
Web Developement Workshop (Oct 2009) SlidesWeb Developement Workshop (Oct 2009) Slides
Web Developement Workshop (Oct 2009) Slides
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 

Dernier

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Dernier (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

MYSQL

  • 2.
  • 3. INSTALLATOIN, CONFIGURATION & COMMANDS -BY H. ANKUSH. JAIN
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 22. Login to MySQL monitor ..ysqlinysql -u[username] -p[password] Example: ..ysqlinysql -uroot -pmysecret
  • 23. Create a database on the sql server. SYNTAX: CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name [create_specification] ... create_specification: [DEFAULT] CHARACTER SET [=] charset_name | [DEFAULT] COLLATE [=] collation_name u-1@srv-1 mysqlart $ mysql -u root Welcome to the MySQL monitor. Commands end with ; or . Your MySQL connection id is 5 to server version: 4.0.14-log Type 'help;' or '' for help. Type '' to clear the buffer. mysql> create database sysops; Query OK, 1 row affected (0.00 sec) mysql> quit Bye u-1@srv-1 mysqlart $ Example:
  • 24. List all databases on the sql server. SYNTAX: mysql> show databases; mysql> SHOW DATABASES; +----------+ | Database | +----------+ | info     | | java2s   | | mysql    | | t        | | test     | | ttt      | +----------+ 6 rows in set (0.00 sec)
  • 25. Switch to a database. mysql> use [db name];
  • 26. To see all the tables in the db. mysql> show tables;
  • 27. CREATE TABLE SYNTAX: CREATE TABLE [table_name] ( [column_name1] INT AUTO_INCREMENT, [column_name2] VARCHAR(30) NOT NULL, [column_name3] ENUM('guest', 'customer', 'admin')NULL, [column_name4] DATE NULL, [column_name5] VARCHAR(30) NOT NULL, [column_name6] DATETIME NOT NULL, [column_name7] CHAR(1) NULL, [column_name8] BLOB NULL, [column_name9] TEXT NOT NULL, UNIQUE(username), PRIMARY KEY (column_name1) ); Example: CREATE TABLE user ( userid INT AUTO_INCREMENT, username VARCHAR(30) NOT NULL, group_type ENUM('guest', 'customer', 'admin') NULL, date_of_birth DATE NULL, password VARCHAR(30) NOT NULL, registration_date DATETIME NOT NULL, account_disable CHAR(1) NULL, image BLOB NULL, comment TEXT NOT NULL, UNIQUE(username), PRIMARY KEY (userid) );
  • 28.
  • 29.
  • 30.
  • 31.
  • 32. Change column name &quot;male&quot; into &quot;gender&quot; in table user and change the type to VARCHAR(3) and allow NULL values. Syntax: ALTER TABLE [table_name] CHANGE [old_column] [new_column] VARCHAR(3) NULL; Example: ALTER TABLE user CHANGE male gender VARCHAR (3) NULL;
  • 33. Change the size of column &quot;gender&quot; from 3 to 6 in table user. Syntax: ALTER TABLE [table_name] MODIFY [column_name] VARCHAR(6); Example: ALTER TABLE user MODIFY gender VARCHAR(6);
  • 34.
  • 35.
  • 36. Show field formats of the selected table. Syntax: DESCRIBE [table_name]; Example: DESCRIBE mos_menu;
  • 37. To see database's field formats. mysql> describe [table name];
  • 38. To delete a db. mysql> drop database [database name]; Example: DROP DATABASE demodb;
  • 39. To delete a table. mysql> drop table [table name]; Example: DROP TABLE user;
  • 40. Show all data in a table. mysql> SELECT * FROM [table name]; Example: SELECT * FROM mos_menu;
  • 41. Show all records from mos_menu table containing name &quot;Home&quot;. SELECT * FROM [table_name] WHERE [field_name]=[value]; Example: SELECT * FROM mos_menu WHERE name = &quot;Home&quot;;
  • 42. Returns the columns and column information pertaining to the designated table. mysql> show columns from [table name];
  • 43. Show certain selected rows with the value &quot;whatever&quot;. mysql> SELECT * FROM [table name] WHERE [field name] = &quot;whatever&quot;;
  • 44. Show all records containing the name &quot;Bob&quot; AND the phone number '3444444'. mysql> SELECT * FROM [table name] WHERE name = &quot;Bob&quot; AND phone_number = '3444444';
  • 45. Show all records not containing the name &quot;Bob&quot; AND the phone number '3444444' order by the phone_number field. mysql> SELECT * FROM [table name] WHERE name != &quot;Bob&quot; AND phone_number = '3444444' order by phone_number;
  • 46. Show all records starting with the letters 'bob' AND the phone number '3444444'. mysql> SELECT * FROM [table name] WHERE name like &quot;Bob%&quot; AND phone_number = '3444444';
  • 47. Show all records starting with the letters 'bob' AND the phone number '3444444' limit to records 1 through 5. mysql> SELECT * FROM [table name] WHERE name like &quot;Bob%&quot; AND phone_number = '3444444' limit 1,5;
  • 48. Use a regular expression to find records. Use &quot;REGEXP BINARY&quot; to force case-sensitivity. This finds any record beginning with a. mysql> SELECT * FROM [table name] WHERE rec RLIKE &quot;^a&quot;;
  • 49. Show unique records. mysql> SELECT DISTINCT [column name] FROM [table name];
  • 50. Show selected records sorted in an ascending (asc) or descending (desc). mysql> SELECT [col1],[col2] FROM [table name] ORDER BY [col2] DESC;
  • 51. Return number of rows. mysql> SELECT COUNT(*) FROM [table name];
  • 52. Sum column. mysql> SELECT SUM(*) FROM [table name];
  • 53. Join tables on common columns. mysql> select lookup.illustrationid, lookup.personid,person.birthday from lookup left join person on lookup.personid=person.personid=statement to join birthday in person table with primary illustration id;
  • 54. Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs. # mysql -u root -p mysql> use mysql; mysql> INSERT INTO user (Host,User,Password) VALUES('%','username',PASSWORD('password')); mysql> flush privileges;
  • 55. Change a users password from unix shell. # [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password 'new-password'
  • 56. Change a users password from MySQL prompt. Login as root. Set the password. Update privs. # mysql -u root -p mysql> SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere'); mysql> flush privileges;
  • 57. Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server. # /etc/init.d/mysql stop # mysqld_safe --skip-grant-tables & # mysql -u root mysql> use mysql; mysql> update user set password=PASSWORD(&quot;newrootpassword&quot;) where User='root'; mysql> flush privileges; mysql> quit # /etc/init.d/mysql stop # /etc/init.d/mysql start
  • 58. Set a root password if there is on root password. # mysqladmin -u root password newpassword
  • 59. Update a root password. # mysqladmin -u root -p oldpassword newpassword
  • 60. Allow the user &quot;bob&quot; to connect to the server from localhost using the password &quot;passwd&quot;. Login as root. Switch to the MySQL db. Give privs. Update privs. # mysql -u root -p mysql> use mysql; mysql> grant usage on *.* to bob@localhost identified by 'passwd'; mysql> flush privileges;
  • 61. Give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs. # mysql -u root -p mysql> use mysql; mysql> INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N'); mysql> flush privileges; or mysql> grant all privileges on databasename.* to username@localhost; mysql> flush privileges;
  • 62. To update info already in a table. mysql> UPDATE [table name] SET Select_priv = 'Y',Insert_priv = 'Y',Update_priv = 'Y' where [field name] = 'user';
  • 63. Delete a row(s) from a table. mysql> DELETE from [table name] where [field name] = 'whatever';
  • 64. Update database permissions/privilages. mysql> flush privileges;
  • 65. Delete a column. mysql> alter table [table name] drop column [column name];
  • 66. Add a new column to db. mysql> alter table [table name] add column [new column name] varchar (20);
  • 67. Change column name. mysql> alter table [table name] change [old column name] [new column name] varchar (50);
  • 68. Make a unique column so you get no dupes. mysql> alter table [table name] add unique ([column name]);
  • 69. Make a column bigger. mysql> alter table [table name] modify [column name] VARCHAR(3);
  • 70. Delete unique from table. mysql> alter table [table name] drop index [colmn name];
  • 71. Load a CSV file into a table. mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '' (field1,field2,field3);
  • 72. Dump all databases for backup. Backup file is sql commands to recreate all db's. # [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql
  • 73. Dump one database for backup. # [mysql dir]/bin/mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql
  • 74. Dump a table from a database. # [mysql dir]/bin/mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql
  • 75. Restore database (or database table) from backup. # [mysql dir]/bin/mysql -u username -ppassword databasename < /tmp/databasename.sql