Сброс пароля сервера mysql в Linux
Опубликовано: 24.03.2017
удивительно, почему-либо пароль не подходит, потому буду изменять его, как это сделать я покажу ниже:
Останавливаем службу MySQL сервера:
ekzorchik@srv-mon:~$ sudo service mysql stop
mysql stop/waiting
Запускаем mysqld конфигурацию:
ekzorchik@srv-mon:~$ sudo mysqld
150529 14:04:39 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
150529 14:04:39 [Note] mysqld (mysqld 5.5.43-0ubuntu0.14.04.1) starting as process 19797 …
После открываем еще одну консоль на сервере и подключаемся под юзером root в базу mysql без указания какого бы то нибыло пароля:
CentOS сброс пароля root пользователя
ekzorchik@srv-mon:~$ mysql -u 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 1
Server version: 5.5.43-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
WAMP Error 1045 phpMyAdmin : 'root'@'localhost' (using password: NO)
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>
После этого заменяем текущий пароль на новый, т. е. Можно сказать сбрасываем:
mysql> update user set password=password('712mbddr@') where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings:
0mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
Убиваем процесс mysqld:
ekzorchik@srv-mon:~$ sudo killall mysqld
Запускаем службу MySQL сервера:
ekzorchik@srv-mon:~$ sudo service mysql start
mysql start/running, process 9512
Отлично, сейчас пробуем зайти под рутом в консоль.
ekzorchik@srv-mon:~$ mysql -u root -p712mbddr@
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.5.37-0ubuntu0.12.04.1 (Ubuntu)
Copyright (c) 2000, 2014, 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>
Отлично, пароль сброшен и следующих вход в консоль администрирования удачно произведен. Могу с уверенностью сказать, что задачка выполнена.
06.08.2016
А вот на Ubuntu 14.04.4 Server amd64 у меня ни в какую не выходил все что описано выше, пришлось сделать по-другому:
aollo@srv-glpi:~$ sudo /etc/init.d/mysql stop
* Stopping MySQL database server mysqld
aollo@srv-glpi:~$ sudo mysqld_safe —skip-grant-tables &
[1] 23863
aollo@srv-glpi:~$ 160806 13:40:52 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.
160806 13:40:52 mysqld_safe Logging to ‘/var/log/mysql/error.log’.
160806 13:40:52 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Сейчас в другой консоли присоединенной к данное серверу:
aollo@srv-glpi:~$ sudo dpkg-reconfigure glpi
apache2_invoke glpi: already enabled
* Reloading web server apache2 *
dbconfig-common: writing config to /etc/dbconfig-common/glpi.conf
granting access to database glpi for glpi@localhost: already exists.
creating database glpi: already exists.
populating database via sql… done.
dbconfig-common: flushing administrative password
и все дальше по текущей заметке
На этом заметка завершена и до встречи с почтением создатель блога — Олло Александр (т. е. Ekzorchik).