Skip to content Перейти до змісту


How to reset a lost MySQL root password Як відновити втрачені кореневого пароля MySQL

LinuxБезпекаWindows

Have you ever forgotten your MySQL root password? Ви коли-небудь забув пароль MySQL корінь? It's one of those things that just happens despite the numerous precautions one might take. Це одна з тих речей, що саме відбувається, незважаючи на численні запобіжні заходи можна вжити. As a result, you are locked out of your database server. В результаті, ви позбавлені можливості сервера баз даних. You can't create new databases and are left with little control over the state of your database server. Ви не можете створювати нові бази даних і залишилося мало контроль за станом сервера баз даних. In such situations knowing how to regain root access to your database server comes in handy. У таких ситуаціях знаючи, як відновити доступ до кореневих сервером баз даних дуже зручно. So here's what you can do to reset the password for the root user in MySQL on both Windows and Linux. Отже, ось що ви можете зробити, щоб змінити пароль для кореневого користувача в MySQL на обох Windows і Linux.

Windows Users: Користувачам Windows:

Log on to your server as the Administrator. Увійдіть на вашому сервері як адміністратор. Kill the MySQL server if it's running. Kill The MySQL сервер, якщо він запущений. To do this you need the Windows Services Manager , so click on the Start Menu , then go to the Control Panel , then to the Administrative Tools , and select Services . Для цього вам необхідно Менеджер сервісів Windows, тому клацніть по меню "Пуск", потім виберіть команду Панель керування, потім Адміністрування, а потім виберіть Служби. Here look for the MySQL server and stop it. Ось погляд на сервер MySQL і зупинити його. If it's not listed there and MySQL is till running it means that MySQL is not running as a service. Якщо це не перераховані в ньому і MySQL поки це працює, значить, MySQL не запущений в якості служби. In that case you need to load the Task Manager which you should be able to access using the key combination of Ctrl+Alt+Del . У цьому випадку вам потрібно завантажити Диспетчер завдань якого ви повинні мати можливість доступу за допомогою ключа комбінацію Ctrl + Alt + Del. Now kill the MySQL process. Тепер убийте MySQL процесу.

With the MySQL process stopped you need to force a change of passwords on MySQL using a combination of the UPDATE and FLUSH options. У процесі MySQL зупинив потрібно змусити змінити паролі на MySQL, використовуючи комбінацію UPDATE і Е'ізн варіанти. So launch your favorite text editor and create a new file. Таким запуск ваш улюблений текстовий редактор і створити новий файл. Enter the following text into the file replacing “NewMySQLPassword” with your new password: Введіть наступний текст в файл замінивши слова "NewMySQLPassword" з новим паролем:

UPDATE mysql.user SET Password=PASSWORD(”NewMySQLPassword”) WHERE User='root'; UPDATE mysql.user SET Password = PASSWORD ( "NewMySQLPassword") WHERE User = 'корінь';
FLUSH PRIVILEGES; FLUSH PRIVILEGES;

What the first line does is that it updates the value of the field “Password” in the table mysql.user for the user “root” to “NewMySQLPassword”. Те, що перший рядок це те, що він оновлює значення поля "Пароль" в таблиці mysql.user для користувача "корінні" до "NewMySQLPassword". The second line flushes the old set of privileges and makes sure your new password is used everywhere. Друга лінія скидає стару набір привілеїв і робить, що ваш новий пароль буде використовуватися повсюдно. Save this text as C:\mysql_reset.txt . Збережіть цей текст в C: \ mysql_reset.txt.

Next, you need to start your MySQL server passing this file as a configuration parameter. Далі, вам потрібно почати ваш сервер MySQL проходження цього файлу як параметр конфігурації. Launch a terminal by going to the Start Menu , then to Run , and then type cmd and hit Enter. Запуск терміналу, зайшовши в меню "Пуск", потім "Виконати" і введіть команду CMD та натисніть Enter. Now enter the following command: Тепер введіть наступну команду:

C:\mysql\bin\mysqld-nt --init-file=C:\mysql_reset.txt C: \ MySQL \ bin \ туздИ-NT - INIT-File = C: \ mysql_reset.txt

Once the server is done starting delete the file C:\mysql_reset.txt . Після того як сервер здійснюється починаючи видалити файл C: \ mysql_reset.txt. Your MySQL root password should be reset now. Ваш MySQL пароля повинні бути скинуті зараз. Now restart your MySQL server again. Тепер перезавантажте ваш MySQL сервер. Go back to the Windows Services Manager again to do that. Поверніться до Диспетчер послугами знову зробити це. Your new MySQL root password should work for you now. Ваш новий корінь MySQL пароль повинен працювати на вас зараз.

Linux Users: Linux Users:

Log on to your Linux machine as the root user. Увійдіть на вашій машині Linux в якості кореневого користувача. The steps involved in resetting the MySQL root password are to stop the MySQL server, restart it without the permissions active so you can log into MySQL as root without a password, set a new password, and then restart it normally. Етапи скидання пароля MySQL кореня, щоб зупинити сервер MySQL, перезапустити його без дозволу Активні так що ви можете увійти в MySQL як корінь без пароля, встановити новий пароль, а потім запустити його як звичайно. Here's how you do it. От як ви це робите. First, stop the MySQL server: По-перше, зупинити сервер MySQL:

# /etc/init.d/mysql stop # / І т.д. / init.d / зупинка MySQL

Now start the MySQL server using the --skip-grant-tables option, which will run the server without loading the permissions settings: Тепер запустіть MySQL сервером, використовуючи - Skip-грантів столи варіант, який буде працювати на сервері без завантаження дозволів налаштування:

# mysqld_safe --skip-grant-tables & # Mysqld_safe - Skip-грантів столи &

The & option at the end makes the command you have executed run as a background process. & Опцію в кінці робить команда, яку ви виконали виконується як фоновий процес. Now log on to your MySQL server as root: Тепер вхід в ваш сервер MySQL root'ом:

# mysql -u root # MySQL-гооЬ

It should allow you in without prompting for a password. Вона повинна дозволити вам без запиту пароля. The following steps will set the new password: Наступні кроки будуть встановити новий пароль:

mysql> use mysql; MySQL> Використання MySQL;
mysql> update user set password=PASSWORD(”NewMySQLPassword”) where User='root'; MySQL> Update користувачеві встановити Password = пароль ( "NewMySQLPassword"), де користувач = 'корінь';
mysql> flush privileges; > РШЗН привілеїв;
mysql> quit MySQL> Вихід

Replace “NewMySQLPassword” with your own password. Замінити "NewMySQLPassword" на свій власний пароль. Here's what happens here. Ось що відбувається тут. The first line selects the MySQL configuration tables. Перша лінія вибирає MySQL таблиць конфігурації. The second line updates the value of the field “Password” for the user “root” to “NewMySQLPassword”. Оновлення другому рядку значення поля "Пароль" для користувача "корінні" до "NewMySQLPassword". The third line flushes the old set of privileges and makes sure your new password is used everywhere. Третій рядок не скидає стару набір привілеїв і робить, що ваш новий пароль буде використовуватися повсюдно. Now, the last step is to restart the server normally and use your new root password to log in: Тепер останній крок, щоб перезапустити сервер нормально і використовувати ваш новий пароль кореня увійти в систему:

# /etc/init.d/mysql stop # / І т.д. / init.d / зупинка MySQL
# /etc/init.d/mysql start # / І т.д. / init.d / MySQL початок
# mysql -u root -pNewMySQLPassword # MySQL-У кореневого pNewMySQLPassword

Congratulations, your new MySQL root password is set and your MySQL server is ready to be used again. Вітаємо, ваш новий корінь MySQL встановлений пароль і ваш MySQL сервер готовий бути використані знову. Remember to update all your applications to use this password if you are using it anywhere. Пам'ятайте, щоб оновити всі додатки для використання цього пароля, якщо ви використовуєте його в будь-якому місці.

Posted in Опубліковано в Guest Blogger Гість Blogger , , Linux Linux , , Security Безпека , , Windows Windows . .

Related Posts: Схожі повідомлення:

How to remotely access your MySQL in a secure manner Віддалений доступ до MySQL в безпечному режимі
How to setup slow query logging in MySQL Як налаштувати журнал повільних запитів в MySQL
Bash one liner – how to compress, move, and extract a directory Баш Один балон - як стиснути, переміщати і екстракт каталозі
How to enable the root user account in Ubuntu Linux Як включити обліковий запис користувача root в Ubuntu Linux
How to install and setup Apache, MySQL and PHP in Windows Як встановити та налаштувати Apache, MySQL та PHP на Windows

5 Responses 5 відповідей

Stay in touch with the conversation, subscribe to the Залишайтеся на зв'язку при розмові, підпишіться на RSS feed for comments on this post RSS-канал для коментарів на цю посаду . .

  1. Marcos Santos says Маркос Сантос говорить

    OI como faço para recuperar a senha do root do linux Kurumin О. корисне faço пункт Recuperar Пароль роблять корінні зробити Linux Kurumin

  2. Manfred Манфред says говорить

    BTW the syntax above is missing a - До речі синтаксис вище, зниклих безвісти --
    There should be a double minus sign in front of the init. Там повинна бути подвійний знак мінус перед Init. Do that and the commands work fine. Зробити це і тонка робота команд. Looking at it, its missing elsewhere too – so might be your blog s/w converting double en dash to em dash Дивлячись на нього, своїх зниклих без вести в інших місцях теж - так міг би бути Ваш блог S / W подвійним перетворенням тире в тирі

    C:\mysql\bin\mysqld-nt -–init-file=C:\mysql_reset.txt C: \ MySQL \ bin \ туздИ-NT - INIT-File = C: \ mysql_reset.txt

  3. Ross McKillop Росс McKillop says говорить

    Thanks Manfred – you're right, it did convert the double-dashes into a single dash. Завдяки Манфред - Ви маєте рацію, це було перетворити подвійне тире в тирі. It's all fixed now. Це все тепер виправлена. Thanks again! Ще раз спасибі!

  4. DaiLaughing DaiLaughing says говорить

    Much simpler than the “official” version pointed out by xxxxxxx. Набагато простіше, ніж "офіційні" версії вказували XXXXXXX. Nicely written, thanks. Nicely написано, спасибо.



Some HTML is OK Деякі HTML нормально

or, reply to this post via або відповісти на цей пост через trackback Архів . .