Passwd change
---------
For every database, you should set the root or sa passwords to something other than the default, unless you want to get hacked. For mysql, the system administrator user is called root. You will use the mysqladmin utility from a command line to set the new password.
Syntax:
# mysqladmin -u root password “new_password”
# mysqladmin -u root -h host_name password “new_password”
Example:
# mysqladmin -u root password Pa55w0rD
# mysqladmin -u root -h localhost password linuxgEEks
You need to restart the database server after this change
# /etc/init.d/mysql restart
-------------------------
Simple
# mysqladmin -u root -p password mynewpassword # chane passwd
# mysql -u root -pmynewpassword # login New psswd
Change a Password for MySQL on Linux via Command Line
First we’ll login to the MySQL server from the command line with the following command:
mysql -u root -p
In this case, I’ve specified the user root with the -u flag, and then used the -p flag so MySQL prompts for a password. Enter your current password to complete the login.
Now switch to the appropriate MySQL database with the following command:
use mysql;
Next we’ll update the password for all MySQL users with the name root. Be sure to replace your_new_password with the actual new password:
update user set password=PASSWORD('your_new_password') where User='root';
Note: You can change the password for any user with the above command. Simply specify that user’s username in place of root.
Finally, reload the privileges:
flush privileges;
Now you’re all set to exit MySQL!
quit
-----------------------X---------------------
Reset Forgotten MySQL Root Password
# systemctl stop mariadb.service
systemctl stop mysql
service mysqld stop
First things first. Log in as root and stop the mysql daemon. Now lets start up the mysql daemon and skip the grant tables which store the passwords.
mysqld_safe --skip-grant-tables &
You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.
mysql --user=root mysql
update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
exit;
For MySQL 5.6 or Below
# mysql -u root mysql> USE mysql; mysql> UPDATE user SET password=PASSWORD("NEW-PASSWORD") WHERE User='root'; mysql> FLUSH PRIVILEGES; mysql> quit
For MySQL 5.7 or Above
# mysql -u root mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD("NEW-PASSWORD"); mysql> FLUSH PRIVILEGES; mysql> quit
# mysqladmin -u root -p shutdown
systemctl start mariadb.service
systemctl start mysql
service mysqld start
systemctl enable mariadb.service
mysql -u root -p
Now kill your running mysqld, then restart it normally. You should be good to go. Try not to forget your password again.
----------------X-----------------
# systemctl stop mariadb.service
systemctl stop mysql
service mysqld stop
Start up safe mode
mysqld_safe --skip-grant-tables &
You may need to type Enter twice.
Log into MySQL as root:
mysql -u root
Change to the mysql database, which handles the settings for MySQL itself:
use mysql;
Update the password for the root user:
update user set password=PASSWORD("the new password you want to use") where User='root';
Refresh the MySQL user privileges:
flush privileges;
Exit MySQL:
exit
If this doesn't work, you can try force the application to quit by pressing CTRL-C on your keyboard.
# mysqladmin -u root -p shutdown
systemctl start mariadb.service
systemctl start mysql
service mysqld start
-------------------------------------------------
Reset MySQL root password
Step 1: Stop mysql service
# service mysqld stop (Centos or Fedora)
#service mysql stop (Ubuntu or Debian)
Step 2:
Restart the MySQL server with the —skip-grant-tables option. Using the following command:
# mysqld_safe --skip-grant-tables &
Step 3:
Log into MySQL using the following command:
Step 4:
At the mysql> prompt, reset the password. Using following command, replacing NEW-PASSWORD with the new root password:
Step 5:
Type following command:
UPDATE mysql.user SET Password=PASSWORD('NEW-PASSWORD') WHERE User='root';
mysql
Step 7: Start mysql service
Step 6: Stop mysql server
FLUSH PRIVILEGES;
exit;
# mysqladmin -u root -p shutdown
# service mysqld start (Centos or Fedora)
# service mysql start (Ubuntu or Debian)
---------------------------------X---------------------------------------------------------
Reset Postfix Admin password
1. Get the Encrypted Version of the string that you want to set as password :
dovecot -s MD5-CRYPT -p <yournewpassword> | sed ‘s/{MD5-CRYPT}//’
2. Copy the output
3. Login to Mysql database
4. Use database Vmail or whatever in your case.
5.Run the following query :
update admin set password='<above copied output>’ where username = ‘<username>’
####################
Admin password Lost
doveadm pw -s SHA512-CRYPT -p YOUR_NEW_PASSWORD
And edit database :
docker exec -it mariadb bash
# mysql -u root -p
mysql> use postfix;
mysql> UPDATE admin SET password = '{SHA512-CRYPT}HASH' WHERE username = 'user@domain.tld';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> quit
exit
##################
Postfixadmin
1. Делаем шифрованный пароль при помощи команды
dovecot pw -s MD5-CRYPT -p password | sed 's/{MD5-CRYPT}//'
2. Заходи в mysql
mysql -u root –p
3. Выбираем базу
use postfixadmin;
4. Смотрим учетку администратора.
select * from admin;
5. Меняем пароль
update admin set password='хеш пароль' where username='admin@blablabla.ru';
-----------------------------------------------------
Ubuntu 11.1
dovecot
doveadm pw -s MD5-CRYPT -p YOUR_PASSWORD | sed 's/{MD5-CRYPT}//'
$1$ZbwsgmXZ$W.Rg5Cr8SuP663u41xTja/
# mysql -u postfix_admin -p
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mail |
+--------------------+
2 rows in set (0.00 sec)
mysql> use mail;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+-----------------------+
| Tables_in_mail |
+-----------------------+
| admin |
| alias |
| alias_domain |
| config |
| domain |
| domain_admins |
| fetchmail |
| log |
| mailbox |
| quota |
| quota2 |
| vacation |
| vacation_notification |
+-----------------------+
13 rows in set (0.00 sec)
select * from admin;
1
select * from admin;
mysql> select * from admin;
+-----------------------------------+------------------------------------+---------------------+---------------------+--------+
| username | password | created | modified | active |
+-----------------------------------+------------------------------------+---------------------+---------------------+--------+
| arielfx@emang.ganteng.de | $1$f383ade6$zU86FBNFzlJHStY5LLLEB/ | 2014-03-09 18:02:58 | 2015-02-16 21:03:50 | 0 |
+-----------------------------------+------------------------------------+---------------------+---------------------+--------+
1 rows in set (0.00 sec)
mysql>
mysql> update admin set password='$1$ZbwsgmXZ$W.Rg5Cr8SuP663u41xTja/' where username='arielfx@emang.ganteng.de';
---------