SlideShare uma empresa Scribd logo
1 de 3
Baixe o MongoDB essa é a versão 32 bits se o teu pc for 64, baixa esse a versão 64 bits
aqui. Enquanto baixa, vai lá no C: e cria duas pastas:
mongodb
data


        Dentro da pasta data cria uma pasta chamada db
        Vai ficar exatamente assim:


c:/mongodb
c:/data/db


        Assim que acabar o download do MongoDB, crie uma pasta no seu C: com o nome
mongodb extraia todos os arquivos para esta pasta. Pronto, agora vamos em Iniciar > Executar
> e digite: cmd
Agora no prompt de comando digite “cd ” sem aspas, entrando no C:
Entre na pasta bin do MongoDB com o comando:
cd mongodbbin
e digite mongod


        Isso mongod mesmo, com o d no final. A tela deverá estar assim:




                Pronto o teu servidor está rodando. Se quiser acesse a página do mongodb
em http://localhost:27017 se entrar esta tudo ok. Provavelmente você verá esta mensagem:
“You are trying to access MongoDB on the native driver port. For http diagnostic access, add
1000 to the port number”.
Agora vamos juntar o MongoDB e PHP instalando as dll’s do driver php usando o
WAMP, mas o processo é bem semelhante se você quiser instalar o MongDB e PHP sem usar o
WAMP.


         O WAMP usa o php 5.3 vc6 ts. Vamos baixar este drive:


http://github.com/downloads/mongodb/mongo-php-driver/mongo-1.0.6-r1-php5.3vc6ts.zip



        No site do MongoDB tem um vários drivers para outros projetos e outras versões do
PHP: http://www.mongodb.org/display/DOCS/Downloads
Extraia a dll do MongoDB para a pasta do PHP, no WAMP você coloca em:
C:wampbinphpphp5.3.1ext
obs.: esse caminho é do meu wamp, veja onde você instalou ele.

        Agora vá no ícone do WAMP feche e abra-o novamente, quando ele estiver aberto
clique uma vez nele vai em PHP > PHP extensions e procure por php_mongo.dll achando essa
extensão habilite-a.


         Fecha e abre o WAMP novamente.

        Pronto, já é pra tudo funcionar. Entrem em http://www.phpmoadmin.com/
Baixa ele e coloca na sua pasta do apache, a que você usa para rodar suas páginas,
normalmente é a www.

Aqui esta um exemplo de uma página utilizando a extensão.

<?php
$conexao = new        Mongo(); //cria a conexao com o banco
$db = $conexao->testebd; //cria/utilize uma database
$collection =       $db->usuarios; //cria/utilize uma tabela
/*
           getTime função que mostrará o tempo gasto no processamento
*/
function getTime(){
     static $tempo;
     if( $tempo == NULL ){
           $tempo =     microtime(true);
     }else{
           echo 'Tempo      (segundos): '.(microtime(true)-$tempo).'';
     }
}
echo '<h1>Inserindo 1 milhão de registros</h1>';
getTime();
for($i=0;$i<1000000;$i++){ //1 milhão de registros.
     $obj = array( "titulo" => "Artigo NOSQL do iMasters", "autor" =>
"Suissa" );
     $collection->insert($obj);//insere na collection usuarios
}
$cursor = $collection->find($filter);
$cursor->limit(10); //so mostra 10 registros
var_dump($cursor->count(true));
var_dump($cursor->count());
getTime();
$filter = array(
     "titulo" => "Artigo NOSQL do iMasters"
);
echo    "<hr />";
foreach ($cursor as $obj) { //andamos no objeto para mostrar
     echo    $obj["title"]. " - " . $obj["_id"] . "<br/>n";
}
$conexao->close(); //fecha conexão com o banco
?>




Isso mesmo, ele vai inserir 1 milhão de registros e vai retornar o tempo, se quiserem
comentem o resultado aqui para agente comparar.


Abraços.

Mais conteúdo relacionado

Destaque

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Destaque (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Como instalar mongodb no windows

  • 1. Baixe o MongoDB essa é a versão 32 bits se o teu pc for 64, baixa esse a versão 64 bits aqui. Enquanto baixa, vai lá no C: e cria duas pastas: mongodb data Dentro da pasta data cria uma pasta chamada db Vai ficar exatamente assim: c:/mongodb c:/data/db Assim que acabar o download do MongoDB, crie uma pasta no seu C: com o nome mongodb extraia todos os arquivos para esta pasta. Pronto, agora vamos em Iniciar > Executar > e digite: cmd Agora no prompt de comando digite “cd ” sem aspas, entrando no C: Entre na pasta bin do MongoDB com o comando: cd mongodbbin e digite mongod Isso mongod mesmo, com o d no final. A tela deverá estar assim: Pronto o teu servidor está rodando. Se quiser acesse a página do mongodb em http://localhost:27017 se entrar esta tudo ok. Provavelmente você verá esta mensagem: “You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number”.
  • 2. Agora vamos juntar o MongoDB e PHP instalando as dll’s do driver php usando o WAMP, mas o processo é bem semelhante se você quiser instalar o MongDB e PHP sem usar o WAMP. O WAMP usa o php 5.3 vc6 ts. Vamos baixar este drive: http://github.com/downloads/mongodb/mongo-php-driver/mongo-1.0.6-r1-php5.3vc6ts.zip No site do MongoDB tem um vários drivers para outros projetos e outras versões do PHP: http://www.mongodb.org/display/DOCS/Downloads Extraia a dll do MongoDB para a pasta do PHP, no WAMP você coloca em: C:wampbinphpphp5.3.1ext obs.: esse caminho é do meu wamp, veja onde você instalou ele. Agora vá no ícone do WAMP feche e abra-o novamente, quando ele estiver aberto clique uma vez nele vai em PHP > PHP extensions e procure por php_mongo.dll achando essa extensão habilite-a. Fecha e abre o WAMP novamente. Pronto, já é pra tudo funcionar. Entrem em http://www.phpmoadmin.com/ Baixa ele e coloca na sua pasta do apache, a que você usa para rodar suas páginas, normalmente é a www. Aqui esta um exemplo de uma página utilizando a extensão. <?php $conexao = new Mongo(); //cria a conexao com o banco $db = $conexao->testebd; //cria/utilize uma database $collection = $db->usuarios; //cria/utilize uma tabela /* getTime função que mostrará o tempo gasto no processamento */ function getTime(){ static $tempo; if( $tempo == NULL ){ $tempo = microtime(true); }else{ echo 'Tempo (segundos): '.(microtime(true)-$tempo).''; } }
  • 3. echo '<h1>Inserindo 1 milhão de registros</h1>'; getTime(); for($i=0;$i<1000000;$i++){ //1 milhão de registros. $obj = array( "titulo" => "Artigo NOSQL do iMasters", "autor" => "Suissa" ); $collection->insert($obj);//insere na collection usuarios } $cursor = $collection->find($filter); $cursor->limit(10); //so mostra 10 registros var_dump($cursor->count(true)); var_dump($cursor->count()); getTime(); $filter = array( "titulo" => "Artigo NOSQL do iMasters" ); echo "<hr />"; foreach ($cursor as $obj) { //andamos no objeto para mostrar echo $obj["title"]. " - " . $obj["_id"] . "<br/>n"; } $conexao->close(); //fecha conexão com o banco ?> Isso mesmo, ele vai inserir 1 milhão de registros e vai retornar o tempo, se quiserem comentem o resultado aqui para agente comparar. Abraços.