Jak zmienić hasło root w MySQL?

Z Podręcznik Administratora by OPZ SGU
Wersja z dnia 23:48, 26 paź 2017 autorstwa Blastboy (dyskusja | edycje) (Utworzono nową stronę "<pre>root@vobis:~# /etc/init.d/mysql stop</pre> <pre>[ ok ] Stopping mysql (via systemctl): mysql.service.</pre> <pre>root@vobis:~# mkdir /var/run/mysqld</pre> <pre>root...")
(różn.) ← poprzednia wersja | przejdź do aktualnej wersji (różn.) | następna wersja → (różn.)
Przejdź do nawigacji Przejdź do wyszukiwania
root@vobis:~# /etc/init.d/mysql stop
[ ok ] Stopping mysql (via systemctl): mysql.service.
root@vobis:~# mkdir /var/run/mysqld
root@vobis:~# chown mysql /var/run/mysqld
root@vobis:~# mysqld_safe --skip-grant-tables&
[1] 12355
root@vobis:~# 2017-10-26T15:25:38.165371Z mysqld_safe Logging to syslog.
2017-10-26T15:25:38.170660Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-10-26T15:25:38.198515Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

<pre>root@vobis:~# mysql --user=root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Nowe hasło:

mysql> update user set authentication_string=PASSWORD('NewPassword') where user='root';
Query OK, 1 row affected, 1 warning (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 1
mysql> exit

Bye

root@vobis:~# service mysql stop
root@vobis:~# service mysql start
root@vobis:~# mysqladmin shutdown
root@vobis:~# 2017-10-26T15:40:26.132964Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

[1]+  Done                    mysqld_safe --skip-grant-tables
root@vobis:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>