SlideShare a Scribd company logo
MYSQL MySQL is a database.The data in MySQL is stored in database objects called tables.A table is a collections of related data entries and it consists of columns and rows.Databases are useful when storing information categorically. A company may have a database with the following tables: "Employees", "Products", "Customers" and "Orders".
INSTALLATION It's simple to install MySQL on Linux using the RPM file. 1. Become the superuser if you are working in your account. (Type "su" and the prompt and give the root password). 2. Change to the directory that has the RPM download. 3. Type the following command at the prompt: rpm -ivh "mysql_file_name.rpm" Similarly you can also install the MySQL client and MySQL development RPMs if you've downloaded them. Alternatively, you can install the RPMs through GnoRPM (found under System). 4.Now we'll set a password for the root user. Issue the following at the prompt: mysqladmin -u root password mysqldata
5.It is now time to test the programs. Typing the following at the prompt  starts the mysql client program. The system asks for the the password.Type the root password (mysqldata).If you don't get the prompt for password, it might be because MySQL Server is not running. To start the server, change to /etc/rc.d/init.d/ directory and issue the command ./mysql start (or mysql start depending on the value of the PATH variable on your system). Now invoke mysql client program. 6.Once MySQL client is running, you should get the mysql> prompt. Type the following at this   prompt: show databases;
7. You should now get a display similar to: We've successfully installed MySQL on your system
I The MySQL server configuration normally started during  installation process . The MySQL configuration wizard can be launched by clicking the MySQL server instance configuration wizard entry in the MySQL section of the window start menu. Another way to launch the configuration wizard, you can  launch the MySQLInstanceConfig.exe file directly from bin directory of your MySQL installation. The MySQL server configuration wizard sets configuration variables values in my.ini file in the installation directory for the MySQL server.  --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini" Path "C:\Program Files\MySQL\MySQL Server 5.0" is  installation directory of MySQL server . The --defaults-file option instructs the MySQL server to read the specified file for configuration options when it starts.  The MySQL client and utilities like mysql and mysqldump command-line client are unable to locate the my.ini file locate in the server installation directory. The MySQL use window server 2003, window server 2000 and window XP, MySQL server configuration wizard will configure with MySQL quickly without having to make many decisions about server configuration. CONFIGURATION
The MySQL server [mysqld] port= 3306 socket= /opt/lampp/var/mysql/mysql.sock skip-locking key_buffer = 16M max_allowed_packet = 1M table_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M
Where do all the plugins live plugin_dir = /opt/lampp/lib/mysql/plugin/ Don't listen on a TCP/IP port at all. This can be a security enhancement, if all processes that need to connect to mysqld run on the same host. All interaction with mysqld must be made via Unix sockets or named pipes. Note that using this option without enabling named pipes on Windows (via the "enable-named-pipe" option) will render mysqld useless!
REPLICATION  SLAVE Two methods to configure the host as a replication slave
1) Use the CHANGE MASTER TO command (fully described in our manual) - The syntax is: CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>, MASTER_USER=<user>, MASTER_PASSWORD=<password> ; where you replace <host>, <user>, <password> by quoted strings and <port> by the master's port number (3306 by default). Example: CHANGE MASTER TO MASTER_HOST='125.564.12.1',   MASTER_PORT=3306, MASTER_USER='joe', MASTER_PASSWORD='secret';
Set the variables below. However, in case you choose this method, then start replication for the first time (even unsuccessfully, for example if you mistyped the password in master-password and the slave fails to connect), the slave will create a master.info file, and any later change in this file to the variables' values below will be ignored and overridden by the content of the master.info file, unless you shutdown the slave server, delete master.info and restart the slaver server.
QUERIES A query is a question or a request. With MySQL, we can query a database for specific information and have a recordset returned. EXAMPLE: SELECT LastName FROM Persons
CREATE  The Create command is used to create a table by specifying the tablename, fieldnames and constraints as shown below. Syntax: $createSQL=(&quot;CREATE TABLE tblName&quot;); Example: $createSQL=(&quot;CREATE TABLE tblstudent(fldstudid int(10) NOTNULL AUTO_INCREMENT PRIMARY KEY,fldstudName VARCHAR(250) NOTNULL,fldstudentmark int(4) DEFAULT '0' &quot;);
SELECT The Select command is used to select the records from a table using its field names. To select all the fields in a table, '*' is used in the command. Syntax: $selectSQL=(&quot;SELECT field_names FROM tablename&quot;); Example: $selectSQL=(&quot;SELECT * FROM tblstudent&quot;);
DELETE  The Delete command is used to delete the records from a table using conditions as shown below: Syntax: $deleteSQL=(&quot;DELETE * FROM tablename WHERE condition&quot;); Example: $deleteSQL=(&quot;DELETE * FROM tblstudent WHERE fldstudid=2&quot;);
INSERT The Insert command is used to insert records into a table. The values are assigned to the field names as shown below: Syntax: $insertSQL=(&quot;INSERT INTO tblname(fieldname1,fieldname2..) VALUES(value1,value2,...) &quot;); Example: $insertSQL=(&quot;INSERT INTO Tblstudent(fldstudName,fldstudmark)VALUES(Baskar,75) &quot;);
DELETE The Update command is used to update the field values using conditions. This is done using 'SET' and the fieldnames to assign new values to them. Syntax: $updateSQL=(&quot;UPDATE Tblname SET (fieldname1=value1,fieldname2=value2,...) WHERE fldstudid=IdNumber&quot;); Example: $updateSQL=(&quot;UPDATE Tblstudent SET (fldstudName=siva,fldstudmark=100) WHERE fldstudid=2&quot;);
DROP The Drop command is used to delete all the records in a table using the table name as shown below: Syntax: $dropSQL=(&quot;DROP tblName&quot;); Example: $dropSQL=(&quot;DROP tblstudent&quot;);
UPDATE The update statement is used to change values that are already in a table. SYNTAX: UPDATE <table name> SET <attribute> = <expression> WHERE <condition>; Example: UPDATE STUDENT SET Name = ‘Amar’ WHERE StudID=1001;
TRUNCATE It is used to delete the table. SYNTAX: truncatae table table_name
AS Syntax: SELECT <columns>FROM <existing_table_name>AS <new_table_name> Example:  SELECT t1.name -> FROM artists -> AS t1;  Explanation:  It is used to create a shorthand reference to elements with long names to make the SQL statements shorter and reduce the chance of typos in the longer names.
JOINS SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables.The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables.Tables in a database are often related to each other with keys.A primary key is a column (or a combination of columns) with a unique value for each row. Each primary key value must be unique within the table. The purpose is to bind data together, across tables, without repeating all of the data in every table.
DIFFERENT SQL JOINS JOIN: Return rows when there is at least one match in both tables LEFT JOIN: Return all rows from the left table, even if there are no matches in the right table RIGHT JOIN: Return all rows from the right table, even if there are no matches in the left table FULL JOIN: Return rows when there is a match in one of the tables
INNER JOIN The INNER JOIN keyword return rows when there is at least one match in both tables. SQL INNER JOIN Syntax SELECT column_name(s) FROM table_name1 INNER JOIN table_name2 ON table_name1.column_name=table_name2.column_name; EXAMPLE: LASTNAME FIRST NAME ORDER NO. Hansen Ola 22456 Hansen Ola 24562 Pettersen Kari 77895 Pettersen Kari 44678
LEFT JOIN The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2). SQL LEFT JOIN Syntax: SELECT column_name(s) FROM table_name1 LEFT JOIN table_name2 ON  table_name1.column_name=table_name2.column_name
RIGHT JOIN The RIGHT JOIN keyword Return all rows from the right table (table_name2), even if there are no matches in the left table (table_name1). SQL RIGHT JOIN Syntax: SELECT column_name(s) FROM table_name1 RIGHT JOIN table_name2 ON table_name1.column_name=table_name2.column_name
FULL JOIN The FULL JOIN keyword return rows when there is a match in one of the tables. SQL FULL JOIN Syntax: SELECT column_name(s) FROM table_name1 FULL JOIN table_name2 ON table_name1.column_name=table_name2.column_name
CONSTRAINTS Constraints are used to limit the type of data that can go into a table.Constraints can be specified when a table is created (with the CREATE TABLE statement) or after the table is created (with the ALTER TABLE statement). We have the following constraints: * NOT NULL * UNIQUE * PRIMARY KEY * FOREIGN KEY * CHECK * DEFAULT
FUNCTIONS AGGERATE FUNCTIONS SCALAR FUNCTIONS
AGGERATE FUNCTIONS SQL aggregate functions return a single value, calculated from values in a column. AVG() - Returns the average value COUNT() - Returns the number of rows FIRST() - Returns the first value LAST() - Returns the last value MAX() - Returns the largest value MIN() - Returns the smallest value SUM() - Returns the sum
SCALAR FUNCTIONS SQL scalar functions return a single value, based on the input value. *  UCASE() - Converts a field to upper case * LCASE() - Converts a field to lower case * MID() - Extract characters from a text field * LEN() - Returns the length of a text field * ROUND() - Rounds a numeric field to the number of decimals specified * NOW() - Returns the current system date and time * FORMAT() - Formats how a field is to be displayed

More Related Content

ODP
Mysqlppt
ODP
My sql Syntax
ODP
Prabu's sql quries
PPT
PPT
PDF
Mysql cheatsheet
Mysqlppt
My sql Syntax
Prabu's sql quries
Mysql cheatsheet

What's hot (20)

PPT
PPT
DOC
235689260 oracle-forms-10g-tutorial
DOC
Pl sql using_xml
PPT
Php MySql For Beginners
PDF
PHP and Mysql
PPTX
Oracle: PLSQL Commands
PPT
ODP
My sql
PPTX
WEB TECHNOLOGIES Unit 2
PPT
PDF
Mysql Explain Explained
ODP
PPT
PPT
Oracle training in hyderabad
PPT
ODP
PDF
Columnrename9i
235689260 oracle-forms-10g-tutorial
Pl sql using_xml
Php MySql For Beginners
PHP and Mysql
Oracle: PLSQL Commands
My sql
WEB TECHNOLOGIES Unit 2
Mysql Explain Explained
Oracle training in hyderabad
Columnrename9i
Ad

Viewers also liked (8)

PPT
PHP
PDF
Kwan US Trade in Services
PPT
WEB 2.0
PPT
Nuestro homenaje a
PPT
HTML
PPTX
Japan Institute for Design Promotion, December 21st, 2011, Tokyo, Japan.
PPTX
School magazine evaluation
PPT
CSS
PHP
Kwan US Trade in Services
WEB 2.0
Nuestro homenaje a
HTML
Japan Institute for Design Promotion, December 21st, 2011, Tokyo, Japan.
School magazine evaluation
CSS
Ad

Similar to MYSQL (20)

PPT
My sql with querys
PPT
PPT
Raj mysql
PPT
Mysql
PPTX
Using Mysql.pptx
PPT
MySql slides (ppt)
PPT
mysqlHiep.ppt
PPT
MySQL Database System Hiep Dinh
PPT
Mysql
PPT
My sql presentation
ODP
Mysql1
PPT
Mysql Statments
 
PPT
Diva10
PPT
ODP
PPTX
SQL PPT.pptx
PDF
Mysql basics1
PPT
Mysql ppt
My sql with querys
Raj mysql
Mysql
Using Mysql.pptx
MySql slides (ppt)
mysqlHiep.ppt
MySQL Database System Hiep Dinh
Mysql
My sql presentation
Mysql1
Mysql Statments
 
Diva10
SQL PPT.pptx
Mysql basics1
Mysql ppt

Recently uploaded (20)

PDF
Hybrid model detection and classification of lung cancer
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Getting Started with Data Integration: FME Form 101
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Hindi spoken digit analysis for native and non-native speakers
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
WOOl fibre morphology and structure.pdf for textiles
PPTX
A Presentation on Artificial Intelligence
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
Hybrid model detection and classification of lung cancer
Zenith AI: Advanced Artificial Intelligence
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Approach and Philosophy of On baking technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
A comparative analysis of optical character recognition models for extracting...
Getting Started with Data Integration: FME Form 101
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Hindi spoken digit analysis for native and non-native speakers
Digital-Transformation-Roadmap-for-Companies.pptx
WOOl fibre morphology and structure.pdf for textiles
A Presentation on Artificial Intelligence
MIND Revenue Release Quarter 2 2025 Press Release
gpt5_lecture_notes_comprehensive_20250812015547.pdf
A novel scalable deep ensemble learning framework for big data classification...
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
TLE Review Electricity (Electricity).pptx
Encapsulation_ Review paper, used for researhc scholars

MYSQL

  • 1. MYSQL MySQL is a database.The data in MySQL is stored in database objects called tables.A table is a collections of related data entries and it consists of columns and rows.Databases are useful when storing information categorically. A company may have a database with the following tables: &quot;Employees&quot;, &quot;Products&quot;, &quot;Customers&quot; and &quot;Orders&quot;.
  • 2. INSTALLATION It's simple to install MySQL on Linux using the RPM file. 1. Become the superuser if you are working in your account. (Type &quot;su&quot; and the prompt and give the root password). 2. Change to the directory that has the RPM download. 3. Type the following command at the prompt: rpm -ivh &quot;mysql_file_name.rpm&quot; Similarly you can also install the MySQL client and MySQL development RPMs if you've downloaded them. Alternatively, you can install the RPMs through GnoRPM (found under System). 4.Now we'll set a password for the root user. Issue the following at the prompt: mysqladmin -u root password mysqldata
  • 3. 5.It is now time to test the programs. Typing the following at the prompt starts the mysql client program. The system asks for the the password.Type the root password (mysqldata).If you don't get the prompt for password, it might be because MySQL Server is not running. To start the server, change to /etc/rc.d/init.d/ directory and issue the command ./mysql start (or mysql start depending on the value of the PATH variable on your system). Now invoke mysql client program. 6.Once MySQL client is running, you should get the mysql> prompt. Type the following at this prompt: show databases;
  • 4. 7. You should now get a display similar to: We've successfully installed MySQL on your system
  • 5. I The MySQL server configuration normally started during installation process . The MySQL configuration wizard can be launched by clicking the MySQL server instance configuration wizard entry in the MySQL section of the window start menu. Another way to launch the configuration wizard, you can launch the MySQLInstanceConfig.exe file directly from bin directory of your MySQL installation. The MySQL server configuration wizard sets configuration variables values in my.ini file in the installation directory for the MySQL server. --defaults-file=&quot;C:\Program Files\MySQL\MySQL Server 5.0\my.ini&quot; Path &quot;C:\Program Files\MySQL\MySQL Server 5.0&quot; is installation directory of MySQL server . The --defaults-file option instructs the MySQL server to read the specified file for configuration options when it starts. The MySQL client and utilities like mysql and mysqldump command-line client are unable to locate the my.ini file locate in the server installation directory. The MySQL use window server 2003, window server 2000 and window XP, MySQL server configuration wizard will configure with MySQL quickly without having to make many decisions about server configuration. CONFIGURATION
  • 6. The MySQL server [mysqld] port= 3306 socket= /opt/lampp/var/mysql/mysql.sock skip-locking key_buffer = 16M max_allowed_packet = 1M table_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M
  • 7. Where do all the plugins live plugin_dir = /opt/lampp/lib/mysql/plugin/ Don't listen on a TCP/IP port at all. This can be a security enhancement, if all processes that need to connect to mysqld run on the same host. All interaction with mysqld must be made via Unix sockets or named pipes. Note that using this option without enabling named pipes on Windows (via the &quot;enable-named-pipe&quot; option) will render mysqld useless!
  • 8. REPLICATION SLAVE Two methods to configure the host as a replication slave
  • 9. 1) Use the CHANGE MASTER TO command (fully described in our manual) - The syntax is: CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>, MASTER_USER=<user>, MASTER_PASSWORD=<password> ; where you replace <host>, <user>, <password> by quoted strings and <port> by the master's port number (3306 by default). Example: CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, MASTER_USER='joe', MASTER_PASSWORD='secret';
  • 10. Set the variables below. However, in case you choose this method, then start replication for the first time (even unsuccessfully, for example if you mistyped the password in master-password and the slave fails to connect), the slave will create a master.info file, and any later change in this file to the variables' values below will be ignored and overridden by the content of the master.info file, unless you shutdown the slave server, delete master.info and restart the slaver server.
  • 11. QUERIES A query is a question or a request. With MySQL, we can query a database for specific information and have a recordset returned. EXAMPLE: SELECT LastName FROM Persons
  • 12. CREATE The Create command is used to create a table by specifying the tablename, fieldnames and constraints as shown below. Syntax: $createSQL=(&quot;CREATE TABLE tblName&quot;); Example: $createSQL=(&quot;CREATE TABLE tblstudent(fldstudid int(10) NOTNULL AUTO_INCREMENT PRIMARY KEY,fldstudName VARCHAR(250) NOTNULL,fldstudentmark int(4) DEFAULT '0' &quot;);
  • 13. SELECT The Select command is used to select the records from a table using its field names. To select all the fields in a table, '*' is used in the command. Syntax: $selectSQL=(&quot;SELECT field_names FROM tablename&quot;); Example: $selectSQL=(&quot;SELECT * FROM tblstudent&quot;);
  • 14. DELETE The Delete command is used to delete the records from a table using conditions as shown below: Syntax: $deleteSQL=(&quot;DELETE * FROM tablename WHERE condition&quot;); Example: $deleteSQL=(&quot;DELETE * FROM tblstudent WHERE fldstudid=2&quot;);
  • 15. INSERT The Insert command is used to insert records into a table. The values are assigned to the field names as shown below: Syntax: $insertSQL=(&quot;INSERT INTO tblname(fieldname1,fieldname2..) VALUES(value1,value2,...) &quot;); Example: $insertSQL=(&quot;INSERT INTO Tblstudent(fldstudName,fldstudmark)VALUES(Baskar,75) &quot;);
  • 16. DELETE The Update command is used to update the field values using conditions. This is done using 'SET' and the fieldnames to assign new values to them. Syntax: $updateSQL=(&quot;UPDATE Tblname SET (fieldname1=value1,fieldname2=value2,...) WHERE fldstudid=IdNumber&quot;); Example: $updateSQL=(&quot;UPDATE Tblstudent SET (fldstudName=siva,fldstudmark=100) WHERE fldstudid=2&quot;);
  • 17. DROP The Drop command is used to delete all the records in a table using the table name as shown below: Syntax: $dropSQL=(&quot;DROP tblName&quot;); Example: $dropSQL=(&quot;DROP tblstudent&quot;);
  • 18. UPDATE The update statement is used to change values that are already in a table. SYNTAX: UPDATE <table name> SET <attribute> = <expression> WHERE <condition>; Example: UPDATE STUDENT SET Name = ‘Amar’ WHERE StudID=1001;
  • 19. TRUNCATE It is used to delete the table. SYNTAX: truncatae table table_name
  • 20. AS Syntax: SELECT <columns>FROM <existing_table_name>AS <new_table_name> Example: SELECT t1.name -> FROM artists -> AS t1; Explanation: It is used to create a shorthand reference to elements with long names to make the SQL statements shorter and reduce the chance of typos in the longer names.
  • 21. JOINS SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables.The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables.Tables in a database are often related to each other with keys.A primary key is a column (or a combination of columns) with a unique value for each row. Each primary key value must be unique within the table. The purpose is to bind data together, across tables, without repeating all of the data in every table.
  • 22. DIFFERENT SQL JOINS JOIN: Return rows when there is at least one match in both tables LEFT JOIN: Return all rows from the left table, even if there are no matches in the right table RIGHT JOIN: Return all rows from the right table, even if there are no matches in the left table FULL JOIN: Return rows when there is a match in one of the tables
  • 23. INNER JOIN The INNER JOIN keyword return rows when there is at least one match in both tables. SQL INNER JOIN Syntax SELECT column_name(s) FROM table_name1 INNER JOIN table_name2 ON table_name1.column_name=table_name2.column_name; EXAMPLE: LASTNAME FIRST NAME ORDER NO. Hansen Ola 22456 Hansen Ola 24562 Pettersen Kari 77895 Pettersen Kari 44678
  • 24. LEFT JOIN The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2). SQL LEFT JOIN Syntax: SELECT column_name(s) FROM table_name1 LEFT JOIN table_name2 ON table_name1.column_name=table_name2.column_name
  • 25. RIGHT JOIN The RIGHT JOIN keyword Return all rows from the right table (table_name2), even if there are no matches in the left table (table_name1). SQL RIGHT JOIN Syntax: SELECT column_name(s) FROM table_name1 RIGHT JOIN table_name2 ON table_name1.column_name=table_name2.column_name
  • 26. FULL JOIN The FULL JOIN keyword return rows when there is a match in one of the tables. SQL FULL JOIN Syntax: SELECT column_name(s) FROM table_name1 FULL JOIN table_name2 ON table_name1.column_name=table_name2.column_name
  • 27. CONSTRAINTS Constraints are used to limit the type of data that can go into a table.Constraints can be specified when a table is created (with the CREATE TABLE statement) or after the table is created (with the ALTER TABLE statement). We have the following constraints: * NOT NULL * UNIQUE * PRIMARY KEY * FOREIGN KEY * CHECK * DEFAULT
  • 28. FUNCTIONS AGGERATE FUNCTIONS SCALAR FUNCTIONS
  • 29. AGGERATE FUNCTIONS SQL aggregate functions return a single value, calculated from values in a column. AVG() - Returns the average value COUNT() - Returns the number of rows FIRST() - Returns the first value LAST() - Returns the last value MAX() - Returns the largest value MIN() - Returns the smallest value SUM() - Returns the sum
  • 30. SCALAR FUNCTIONS SQL scalar functions return a single value, based on the input value. * UCASE() - Converts a field to upper case * LCASE() - Converts a field to lower case * MID() - Extract characters from a text field * LEN() - Returns the length of a text field * ROUND() - Rounds a numeric field to the number of decimals specified * NOW() - Returns the current system date and time * FORMAT() - Formats how a field is to be displayed