45
Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireo Jisse Reitsma ([email protected]) - Twitter @yireo phpMyAdmin for beginners phpMyAdmin for beginners

Joomla!: phpMyAdmin for Beginners

  • Upload
    yireo

  • View
    891

  • Download
    5

Embed Size (px)

DESCRIPTION

Presentation on phpMyAdmin for Joomla! beginners

Citation preview

Page 1: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

phpMyAdminfor beginnersphpMyAdminfor beginners

Page 2: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

I am Jisse ReitsmaI am Jisse Reitsma

Developer

Enterpreneur

Founder of YireoJoomla! & Magento

Extensions & development

Documentation & blogs

Joomla! templates-book (NL)

Page 3: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

You are a ...You are a ...

Joomla! site-owner?

Joomla! builder?

Joomla! developer?

Page 4: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

My presentationMy presentation

Part I - MySQL

Part II - phpMyAdmin

Part III - Advanced

Presentation online: http://slideshare.net/yireo

Tweets: @yireo

Page 5: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Part 1:MySQLPart 1:MySQL

Page 6: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Introduction to MySQLIntroduction to MySQL

Part of a stack

Client/server architecture

What is SQL?

Page 7: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

StackStack

Joomla! is based on PHP, which runs on a webserver with PHP-support (like Apache), and data are stored in MySQL.

Examples of webserver “stacks”Linux + Apache + Mysql + PHP = LAMP

MacOS + Apache + Mysql + PHP = MAMP

Windows + Apache + Mysql + PHP = WAMP

Windows + IIS + Mysql + PHP = WIMP

Page 8: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Introduction to MySQLIntroduction to MySQL

Part of a stack

Client/server architecture

What is SQL?

Page 9: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

MySQL serverMySQL server

MySQL on the same server as the websitelocalhost

On a different server but with the same hostermysql12345.hoster.local

On a different server with a different hosterTCP-port 3306 opened in firewall

Security becomes a major issue

Page 10: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

MySQL clientMySQL client

PHP library (“mysql”, “mysqli”, “PDO Mysql”)

Joomla! (PHP “mysqli”)

phpMyAdmin (PHP “mysqli”)

command-line client (SSH)

MySQL GUI client (Navicat, SQLWave, HeidiSQL)

Page 11: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Introduction to MySQLIntroduction to MySQL

Part of a stack

Client/server architecture

What is SQL?Structured Query Language

A way to talk with a relational database

Page 12: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Structured Query LanguageStructured Query Language

A common language to talk with different databases:SELECT field FROM table

DELETE FROM table WHERE id = 2

INSERT INTO table SET id = 2, value = “example”

... but unfortunately there are still a lot of different SQL dialects

Page 13: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

SQL databasesSQL databases

MySQL

MariaDB

Oracle

Microsoft SQL

DB2

PostgreSQL

SQLite

Sybase

Microsoft Access

dBase

Page 14: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Relational databaseRelational database

Store data in multiple database-tabels that relate to each other

Normalisation“Technique, used in the process of designing a database-structure, with the purpose to avoid storing the same data multiple times”

Page 15: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Example 1: Joomla! usersExample 1: Joomla! users

jos_users List of users

jos_usergroups List of usergroups

jos_user_usergroup_map Connection between users and usergroups

Page 16: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Example 2: Joomla! articlesExample 2: Joomla! articles

jos_content List of articles (with a reference to catid & asset_id)

jos_categories List of categories

jos_assets List of authorizations

Page 17: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Part 2:phpMyAdmin

Part 2:phpMyAdmin

Page 18: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

phpMyAdminphpMyAdmin

Overv iew of phpMyAdminSELECT-statementCommon tasks (edit, add, delete)Import & export

Page 19: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Login to phpMyAdminLogin to phpMyAdmin

Direct weblinkControl panel

CPanel, Plesk, DirectAdmincustom panel

Page 20: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Creating a databaseCreating a database

Create an user with corresponding databaseCheck upon the character collation

utf8_unicode_ci / utf8_general_ci

Page 21: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

phpMyAdminphpMyAdmin

Overview of phpMyAdminSELECT-statementCommon tasks (edit, add, delete)Import & export

Page 22: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Opening a database-tableOpening a database-table

Page 23: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

SELECT (1/3)SELECT (1/3)

SELECT * FROM jos_users;

SELECT title,alias FROM jos_content;

SELECT id,username FROM jos_users;

SELECT name,type,enabled FROM jos_extensions;

Page 24: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

SELECT (2/3)SELECT (2/3)

Page 25: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

SELECT (3/3)SELECT (3/3)

Page 26: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

WHEREWHERE

SELECT * FROM x WHERE id = 42;

SELECT * FROM x WHERE id IN (42,43,44,45);

SELECT * FROM x WHERE title = “Example 1”;

SELECT * FROM x WHERE title LIKE “Example%”;

SELECT * FROM x WHERE title LIKE “%example%”;

SELECT * FROM x WHERE created_time > “2012­02”;

Page 27: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Quotes (1/2)Quotes (1/2)

Fout:SELECT from FROM select WHERE where LIKE “a%”;

Correct:SELECT `from` FROM `select` WHERE `where` LIKE “a%”;

Page 28: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Quotes (2/2)Quotes (2/2)

SELECT `id`,`title`,`description` FROM `jos_content` WHERE `title` LIKE “example%” AND `id` IN (25,26,27,28,29,30) AND `created_time` > “”;

Page 29: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

phpMyAdminphpMyAdmin

Overview of phpMyAdminSELECT-statementCommon tasks (ed i t , add , de le te)Import & export

Page 30: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Update, insert, deleteUpdate, insert, deleteUPDATE jos_content 

SET `title`=”Hello World”WHERE `title`=”Hello world”;

INSERT INTO jos_content VALUES `title`=”x”;

DELETE FROM jos_contentWHERE `id`=2;

Page 31: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

phpMyAdminphpMyAdmin

Overview of phpMyAdminSELECT-statementCommon tasks (edit, add, delete)Import & expor t

Page 32: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

ExportExport

Which database tables?Single database-table?

Multiple database-table?

All database-tables? (so: the entire database)

Which data?Table-structure and/or table-data

... or use “Akeeba Backup” (akeebabackup.com)

Page 33: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Part 3:Advanced

Part 3:Advanced

Page 34: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Database table prefixDatabase table prefix

Database table prefixAdjustable during Joomla! installation

Make hacks more difficult (SQL-injection)

RecommendationsDo not choose “jos_”

Do not choose “verylongstring_”. MySQL limits table-name to 64 characters

Page 35: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

User ID 42User ID 42

Default “admin” user had ID 42 (Joomla! 2.5 and older)Make hacks easier (SQL-injection)

Procedure to adjustCreate a new Super User and login as that user

Degrade the old Super User to administrator

Remove that administrator

Update current Super User with old settings

... or use “Akeeba AdminTools” (akeebabackup.com)

Page 36: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Cleanup of database-tablesCleanup of database-tables

TRUNCATE `jos_content`;

Be very careful with thisMake sure to have a backup

Make manual checks with other tables

Page 37: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

JOINsJOINs

LEFT JOINRIGHT JOININNER JOINOUTER JOIN

Page 38: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Example JOINExample JOINSELECT article.*, cat.title AS cat_title 

FROM jos_content AS articleLEFT JOIN  jos_categories AS catON cat.id = a.catidWHERE cat.id = 3;

Page 39: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

UTF-8 & collationsUTF-8 & collations

UTF-8 = Default character set for Joomla!Support for Western languages, Arab, Sanskrit, Klingon

Collations = Interpretation of characterset for storageutf8_general_ci (standard)

utf8_unicode_ci (recommended)

utf8_polish_ci

latin1 (do not use)

Page 40: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Wrong collationWrong collation

If a Joomla! database does not use UTF-8, make sure it does (for every database, table and field)

Set Joomla! site offline

Export the datase to a SQL-file

Change all occurances of “charset=latin1 “ to “charset=utf8”

Import the SQL-file

... or use “Phoca Changing Collation Tool” (phoca.cz)

Page 41: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

MyISAM & InnoDBMyISAM & InnoDB

MyISAM Storage EngineDefault in most hosting environments

InnoDB Storage EngineMore advanced; More tuning options

But not necessary for running Joomla!

Page 42: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Alternatives to MySQLAlternatives to MySQL

PerconaMariaDbNoSQL (Redis)

Page 43: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

Database optimizationsDatabase optimizations

Make sure to have enough RAM (memory)

Variablesquery_cache_size

table_cache, table_size

Vari ous buffers

InnoDB stuff (pool size, threading)

Adjust & monitor; Adjust & monitor

Page 44: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

My presentationMy presentation

Part I - MySQLStack; Client/server; SQL

Part II - phpMyAdminINSERT, SELECT, UPDATE, DELETE;

Create a database, database-user; Import / export;

Part III - AdvancedJOINs; UTF-8, collations; user-ID 42; MyISAM, InnoDB

TRUNCATE; database table prefix; tuning

Page 45: Joomla!: phpMyAdmin for Beginners

Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo

tweet @yireotweet @yireo