joomla!: phpmyadmin for beginners
DESCRIPTION
Presentation on phpMyAdmin for Joomla! beginnersTRANSCRIPT
Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo
phpMyAdminfor beginnersphpMyAdminfor 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)
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?
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
Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo
Part 1:MySQLPart 1:MySQL
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?
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
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?
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
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)
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
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
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
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”
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
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
Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo
Part 2:phpMyAdmin
Part 2:phpMyAdmin
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
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
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
Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo
phpMyAdminphpMyAdmin
Overview of phpMyAdminSELECT-statementCommon tasks (edit, add, delete)Import & export
Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo
Opening a database-tableOpening a database-table
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;
Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo
SELECT (2/3)SELECT (2/3)
Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo
SELECT (3/3)SELECT (3/3)
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 > “201202”;
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%”;
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` > “”;
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
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;
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
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)
Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo
Part 3:Advanced
Part 3:Advanced
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
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)
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
Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo
JOINsJOINs
LEFT JOINRIGHT JOININNER JOINOUTER JOIN
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;
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)
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)
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!
Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo
Alternatives to MySQLAlternatives to MySQL
PerconaMariaDbNoSQL (Redis)
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
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
Presentation “phpMyAdmin for beginners” - http://slideshare.net/yireoJisse Reitsma ([email protected]) - Twitter @yireo
tweet @yireotweet @yireo