2017-05-15 47 views
0

我需要以編程方式創建Neo4j數據庫,然後更改初始密碼。創建數據庫的工作,但我不知道如何更改密碼。如何在以Java編程創建Neo4j數據庫時更改初始密碼

 String graphDBFilePath = Config.getNeo4jFilesPath_Absolute() + "/" + schemaName;  // This is an absolute path. Do not let Neo4j see it. 
     GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(new File(graphDBFilePath)); // See http://neo4j.com/docs/java-reference/current/javadocs/org/neo4j/graphdb/GraphDatabaseService.html 

     // This transaction works 
     try (Transaction tx = graphDb.beginTx()) { 
      Node myNode = graphDb.createNode(); 
      myNode.setProperty("name", "my node"); 
      tx.success(); 
     } 
     // This transaction throws an error 
     Transaction tx = graphDb.beginTx(); 
     try { 
      graphDb.execute("CALL dbms.changePassword(\'Danger42\')");  // "Invalid attempt to change the password" error 
      tx.success(); 
     } catch (Exception ex) { 
       Log.logError("createNewGraphDB() Change Initial Password: " + ex.getLocalizedMessage()); 
     } finally {tx.close(); graphDb.shutdown();} 

回答

0

這可能是版本依賴(我不知道你正在運行的版本),但我認爲其實過程是dbms.security.changePassword

希望這有助於 湯姆

相關問題