MySQL root şifresi, root kullanıcısının MySQL veritabanına tam erişimini sağlar. Mysql veritabanında root şifresi hatırlanmadığında ya da bilinmediği durumlarda aşağıdaki gibi sıfırlanabilir. Sıfırlama için Linux ortamlarda root ile , windows ortamlarda administrator ile bağlantı sağlanması gerekmektedir.
Sıfırlama adımları aşağıdaki gibidir.
Mysql servisinin kapatılması :
Ubuntu ve Debian ise ;
/etc/init.d/mysql stop
CentOS, Fedora, Red Hat Enterprise Linux ya da Oracle Enterprise Linux ise ;
Mysql servisinin şifresiz başlatılması :
mysql -uroot
Yeni şifre verilmesi :
mysql cli üzerinden,
use mysql;
update user set password=PASSWORD(“yenisifre”) where User=’root’;
flush privileges;
quit
Mysql servisinin yeniden başlatılması :
/etc/init.d/mysql start
Yeni şifre ile Mysql veritabanına bağlanılması :
ifre sorduğunda değiştirilen şifre girilip , mysql komut satırına bağlantı sağlanabilir.
Örnek çıktılar aşağıdaki gibi olacaktır.
root@debian:~# /etc/init.d/mysql stop[ ok ] Stopping mysql (via systemctl): mysql.service.root@debian:~# mysqld_safe –skip-grant-tables &[1] 30091root@debian:~# 180922 22:50:31 mysqld_safe Can’t log to error log and syslog at the same time. Remove all –log-error configuration options for –syslog to take effect.180922 22:50:31 mysqld_safe Logging to ‘/var/log/mysql/error.log’.180922 22:50:31 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysqlroot@debian:~# mysql -urootWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.5.55–0+deb8u1 (Debian)Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.mysql> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with –ADatabase changedmysql> update user set password=PASSWORD(“yenisifre”) where User=‘root’;Query OK, 0 rows affected (0.00 sec)Rows matched: 4 Changed: 0 Warnings: 0mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql> quitByeroot@debian:~# /etc/init.d/mysql stop[ ok ] Stopping mysql (via systemctl): mysql.service.root@debian:~# /etc/init.d/mysql start[ ok ] Starting mysql (via systemctl): mysql.service.root@debian:~# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.5.55–0+deb8u1 (Debian)Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.mysql>