Kategorien
PHP XML

read XML String or File

<?php 
$string = <<<XML
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
 <soap:Body>
  <Response xmlns="http://xxx.gateway.xxx.abcd.com">
   <return>
      <transaction_id>1234567</transaction_id>
      <error_code>109</error_code>    
   </return>
  </Response>
 </soap:Body>
</soap:Envelope>
XML;

$xml = new SimpleXMLElement($string); 
$xml->registerXPathNamespace("soap", "http://www.w3.org/2003/05/soap-envelope");
$body = $xml->xpath("//soap:Body");
$error_code = (string)$body[0]->Response->return->error_code;
print_r($error_code); 
?> 

OR

$xml = simplexml_load_string($string); 
 $error_code = (string)$xml->children('soap', true)
                            ->Body
                            ->children()
                            ->Response
                            ->return
                            ->error_code;

Kategorien
Mysql,MariaDB

How to change mysql root password on Linux

  1. Stop mysql Service
    sudo systemctl stop mysql

tep by step instructions:

  1. Start off by stopping the MySQL service:
    sudo systemctl stop mysql
  2. Now, we need to restart the MySQL service but without password privileges being granted. Note that the & at the end of the command just runs the service in the background and will allow us to continue using the current terminal.
    sudo mysqld_safe --skip-grant-tables &
  3. You’ll now be able to connect to the MySQL server as root, without specifying a password: mysql -u root
  4. Now, reset the root password, but first flush the privileges to reload the grants:mysql>
    FLUSH PRIVILEGES;
    mysql> use mysql;
    mysql> update user set plugin=“mysql_native_password“ where User=’root‘;
    mysql> ALTER USER ‚root’@’localhost‘ IDENTIFIED BY ’new_password_here‘;
    mysql> FLUSH PRIVILEGES;
    mysql> quit;
  5. Finally, shut down the MySQL service and start it back up.$ sudo systemctl restart mysql