Skip to content

Instantly share code, notes, and snippets.

@mayeenulislam
Created February 16, 2016 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayeenulislam/7f51d1a3068568fd170e to your computer and use it in GitHub Desktop.
Save mayeenulislam/7f51d1a3068568fd170e to your computer and use it in GitHub Desktop.
Change mySQL password without SQL manager or PHPmyAdmin
<?php
//Connect to mySQL First
$connection = mysql_connect('DB_HOST','DB_USER','DB_PASSWORD');
//Select Database
mysql_select_db('DB_NAME');
//Reset password with SQL UPDATE Query
$SQL="update wp_users set user_pass=MD5('newpassword123here') where user_login='admin'";
//If everything's OK, your password will be reset
if(mysql_query($SQL)){
echo "Your password was succesfully reset!";
}
<?php
//Connect to mySQL First
$connection = mysql_connect('127.0.0.1','user_123','password_123');
//Select Database
mysql_select_db('database_123');
//Reset password with SQL UPDATE Query
$SQL="update wp_users set user_pass=MD5('newpassword123here') where user_login='admin'";
//If everything's OK, your password will be reset
if(mysql_query($SQL)){
echo "Your password was succesfully reset!";
}
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_123');
/** MySQL database username */
define('DB_USER', 'user_123');
/** MySQL database password */
define('DB_PASSWORD', 'password_123');
/** MySQL hostname */
define('DB_HOST', '127.0.0.1');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment