Hướng dẫn reset password root mysql centos 7 - đặt lại mật khẩu root mysql centos 7

Bạn đang sử dụng phiên bản MySQL nào? Tôi đang sử dụng 5.7.10 và có cùng một vấn đề với việc đăng nhập như root

Có hai vấn đề: không có khả năng đăng nhập AS root để bắt đầu và không thể sử dụng ____10 để bắt đầu MySQL để đặt lại mật khẩu root.

Tôi không có câu trả lời để thiết lập mật khẩu gốc trong quá trình cài đặt, nhưng đây là những gì bạn làm để đặt lại mật khẩu gốc

Chỉnh sửa mật khẩu gốc ban đầu khi cài đặt có thể được tìm thấy bằng cách chạy the initial root password on install can be found by running

grep 'temporary password' /var/log/mysqld.log

//dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html

  1. 1. Stop mysql:
    sudo systemctl stop mysqld
    
    2. Set the mySQL environment option 
    sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
    
    3. Start mysql usig the options you just set
    sudo systemctl start mysqld
    
    4. Login as root
    mysql -u root
    
    5. Update the root user password with these mysql commands
    mysql> UPDATE mysql.user SET authentication_string = PASSWORD['MyNewPassword']
        -> WHERE User = 'root' AND Host = 'localhost';
    mysql> FLUSH PRIVILEGES;
    mysql> quit
    
    *** Edit ***
    As mentioned my shokulei in the comments, for 5.7.6 and later, you should use 
       mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
    Or you'll get a warning
    
    6. Stop mysql
    sudo systemctl stop mysqld
    
    7. Unset the mySQL envitroment option so it starts normally next time
    sudo systemctl unset-environment MYSQLD_OPTS
    
    8. Start mysql normally:
    sudo systemctl start mysqld
    
    Try to login using your new password:
    7. mysql -u root -p
    
    2 hiện được sử dụng để chăm sóc MySQL thay vì
    1. Stop mysql:
    sudo systemctl stop mysqld
    
    2. Set the mySQL environment option 
    sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
    
    3. Start mysql usig the options you just set
    sudo systemctl start mysqld
    
    4. Login as root
    mysql -u root
    
    5. Update the root user password with these mysql commands
    mysql> UPDATE mysql.user SET authentication_string = PASSWORD['MyNewPassword']
        -> WHERE User = 'root' AND Host = 'localhost';
    mysql> FLUSH PRIVILEGES;
    mysql> quit
    
    *** Edit ***
    As mentioned my shokulei in the comments, for 5.7.6 and later, you should use 
       mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
    Or you'll get a warning
    
    6. Stop mysql
    sudo systemctl stop mysqld
    
    7. Unset the mySQL envitroment option so it starts normally next time
    sudo systemctl unset-environment MYSQLD_OPTS
    
    8. Start mysql normally:
    sudo systemctl start mysqld
    
    Try to login using your new password:
    7. mysql -u root -p
    
    0 [đó là lý do tại sao bạn gặp lỗi
    1. Stop mysql:
    sudo systemctl stop mysqld
    
    2. Set the mySQL environment option 
    sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
    
    3. Start mysql usig the options you just set
    sudo systemctl start mysqld
    
    4. Login as root
    mysql -u root
    
    5. Update the root user password with these mysql commands
    mysql> UPDATE mysql.user SET authentication_string = PASSWORD['MyNewPassword']
        -> WHERE User = 'root' AND Host = 'localhost';
    mysql> FLUSH PRIVILEGES;
    mysql> quit
    
    *** Edit ***
    As mentioned my shokulei in the comments, for 5.7.6 and later, you should use 
       mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
    Or you'll get a warning
    
    6. Stop mysql
    sudo systemctl stop mysqld
    
    7. Unset the mySQL envitroment option so it starts normally next time
    sudo systemctl unset-environment MYSQLD_OPTS
    
    8. Start mysql normally:
    sudo systemctl start mysqld
    
    Try to login using your new password:
    7. mysql -u root -p
    
    4 - nó chưa được cài đặt]

  2. Cấu trúc bảng

    1. Stop mysql:
    sudo systemctl stop mysqld
    
    2. Set the mySQL environment option 
    sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
    
    3. Start mysql usig the options you just set
    sudo systemctl start mysqld
    
    4. Login as root
    mysql -u root
    
    5. Update the root user password with these mysql commands
    mysql> UPDATE mysql.user SET authentication_string = PASSWORD['MyNewPassword']
        -> WHERE User = 'root' AND Host = 'localhost';
    mysql> FLUSH PRIVILEGES;
    mysql> quit
    
    *** Edit ***
    As mentioned my shokulei in the comments, for 5.7.6 and later, you should use 
       mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
    Or you'll get a warning
    
    6. Stop mysql
    sudo systemctl stop mysqld
    
    7. Unset the mySQL envitroment option so it starts normally next time
    sudo systemctl unset-environment MYSQLD_OPTS
    
    8. Start mysql normally:
    sudo systemctl start mysqld
    
    Try to login using your new password:
    7. mysql -u root -p
    
    5 đã thay đổi.

Vì vậy, để đặt lại mật khẩu gốc, bạn vẫn bắt đầu MySQL với các tùy chọn

1. Stop mysql:
sudo systemctl stop mysqld

2. Set the mySQL environment option 
sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

3. Start mysql usig the options you just set
sudo systemctl start mysqld

4. Login as root
mysql -u root

5. Update the root user password with these mysql commands
mysql> UPDATE mysql.user SET authentication_string = PASSWORD['MyNewPassword']
    -> WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

*** Edit ***
As mentioned my shokulei in the comments, for 5.7.6 and later, you should use 
   mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Or you'll get a warning

6. Stop mysql
sudo systemctl stop mysqld

7. Unset the mySQL envitroment option so it starts normally next time
sudo systemctl unset-environment MYSQLD_OPTS

8. Start mysql normally:
sudo systemctl start mysqld

Try to login using your new password:
7. mysql -u root -p
6 và cập nhật bảng
1. Stop mysql:
sudo systemctl stop mysqld

2. Set the mySQL environment option 
sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

3. Start mysql usig the options you just set
sudo systemctl start mysqld

4. Login as root
mysql -u root

5. Update the root user password with these mysql commands
mysql> UPDATE mysql.user SET authentication_string = PASSWORD['MyNewPassword']
    -> WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

*** Edit ***
As mentioned my shokulei in the comments, for 5.7.6 and later, you should use 
   mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Or you'll get a warning

6. Stop mysql
sudo systemctl stop mysqld

7. Unset the mySQL envitroment option so it starts normally next time
sudo systemctl unset-environment MYSQLD_OPTS

8. Start mysql normally:
sudo systemctl start mysqld

Try to login using your new password:
7. mysql -u root -p
5, nhưng cách bạn thực hiện nó đã thay đổi.

1. Stop mysql:
sudo systemctl stop mysqld

2. Set the mySQL environment option 
sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

3. Start mysql usig the options you just set
sudo systemctl start mysqld

4. Login as root
mysql -u root

5. Update the root user password with these mysql commands
mysql> UPDATE mysql.user SET authentication_string = PASSWORD['MyNewPassword']
    -> WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

*** Edit ***
As mentioned my shokulei in the comments, for 5.7.6 and later, you should use 
   mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Or you'll get a warning

6. Stop mysql
sudo systemctl stop mysqld

7. Unset the mySQL envitroment option so it starts normally next time
sudo systemctl unset-environment MYSQLD_OPTS

8. Start mysql normally:
sudo systemctl start mysqld

Try to login using your new password:
7. mysql -u root -p

Tài liệu tham khảo

Như đã nói tại //dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html,

Ghi chú

Kể từ MySQL 5.7.6, để cài đặt MySQL bằng cách sử dụng phân phối RPM, khởi động và tắt máy chủ được quản lý bởi SystemD trên một số nền tảng Linux. Trên các nền tảng này, mysqld_safe không còn được cài đặt vì nó không cần thiết. Để biết thêm thông tin, xem Phần 2.5.10, Quản lý máy chủ MySQL với SystemD.

Điều này đưa bạn đến //dev.mysql.com/doc/refman/5.7/en/server-man quản lý-using-systemd.html nơi nó đề cập đến

1. Stop mysql:
sudo systemctl stop mysqld

2. Set the mySQL environment option 
sudo systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"

3. Start mysql usig the options you just set
sudo systemctl start mysqld

4. Login as root
mysql -u root

5. Update the root user password with these mysql commands
mysql> UPDATE mysql.user SET authentication_string = PASSWORD['MyNewPassword']
    -> WHERE User = 'root' AND Host = 'localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit

*** Edit ***
As mentioned my shokulei in the comments, for 5.7.6 and later, you should use 
   mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Or you'll get a warning

6. Stop mysql
sudo systemctl stop mysqld

7. Unset the mySQL envitroment option so it starts normally next time
sudo systemctl unset-environment MYSQLD_OPTS

8. Start mysql normally:
sudo systemctl start mysqld

Try to login using your new password:
7. mysql -u root -p
8 về phía dưới của trang.

Các lệnh đặt lại mật khẩu nằm ở dưới cùng của //dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html

  • Đặt lại mật khẩu gốc MySQL
    • Bước 1: Điều kiện tiên quyết
    • Bước 2: Dừng dịch vụ MySQL
    • Bước 3: Bắt đầu MySQL ở chế độ an toàn
    • Bước 4: Kết nối với MySQL
    • Bước 5: Đặt mật khẩu gốc MySQL mới
    • Bước 6: Dừng và bắt đầu dịch vụ MySQL
    • Bước 7: Đăng nhập vào cơ sở dữ liệu

Trong bài viết này, tôi sẽ đưa bạn qua các bước để đặt lại mật khẩu gốc MySQL trên Redhat/Centos 7.

Mật khẩu gốc MySQL cho phép người dùng gốc có quyền truy cập đầy đủ vào cơ sở dữ liệu MySQL.

Sử dụng các bước sau để đặt lại mật khẩu gốc MySQL bằng cách sử dụng giao diện dòng lệnh.

Bước 1: Điều kiện tiên quyết

Bước 2: Dừng dịch vụ MySQL

Bước 2: Dừng dịch vụ MySQL

Bước 3: Bắt đầu MySQL ở chế độ an toàn

[root@localhost ~]# service mariadb stop
Redirecting to /bin/systemctl stop mariadb.service

Bước 3: Bắt đầu MySQL ở chế độ an toàn

Bước 4: Kết nối với MySQL

[root@localhost ~]# sudo mysqld_safe --skip-grant-tables &
[1] 27027
[root@localhost ~]# 191212 13:34:50 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
191212 13:34:51 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

Bước 4: Kết nối với MySQL

Bước 5: Đặt mật khẩu gốc MySQL mới

[root@localhost ~]# mysql -u root
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.20-MariaDB MariaDB Server

Copyright [c] 2000, 2016, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [[none]]>

Bước 5: Đặt mật khẩu gốc MySQL mới

Bước 6: Dừng và bắt đầu dịch vụ MySQL

MariaDB [[none]]> use mysql;
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
MariaDB [mysql]> update user set authentication_string=PASSWORD["root@123$"] where User='root';
Query OK, 4 rows affected [0.03 sec]
Rows matched: 4 Changed: 4 Warnings: 0

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected [0.24 sec]

MariaDB [mysql]> quit
Bye

Bước 6: Dừng và bắt đầu dịch vụ MySQL

Bước 7: Đăng nhập vào cơ sở dữ liệu

[root@localhost ~]# service mariadb stop

Trong bài viết này, tôi sẽ đưa bạn qua các bước để đặt lại mật khẩu gốc MySQL trên Redhat/Centos 7.

[root@localhost ~]# service mariadb start

Bước 7: Đăng nhập vào cơ sở dữ liệu

Trong bài viết này, tôi sẽ đưa bạn qua các bước để đặt lại mật khẩu gốc MySQL trên Redhat/Centos 7.

[root@localhost ~]# mysql -u root -p
Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.
Server version: 10.1.20-MariaDB MariaDB Server

Copyright [c] 2000, 2016, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [[none]]>

Mật khẩu gốc MySQL cho phép người dùng gốc có quyền truy cập đầy đủ vào cơ sở dữ liệu MySQL.

Sử dụng các bước sau để đặt lại mật khẩu gốc MySQL bằng cách sử dụng giao diện dòng lệnh.

Làm cách nào để thay đổi mật khẩu gốc mysql trong centos 7?

Cách đặt lại mật khẩu gốc MySQL trên redhat/centos 7..
Bước 1: Điều kiện tiên quyết ..
Bước 2: Dừng dịch vụ MySQL ..
Bước 3: Bắt đầu MySQL ở chế độ an toàn ..
Bước 4: Kết nối với MySQL ..
Bước 5: Đặt mật khẩu gốc MySQL mới ..
Bước 6: Dừng và bắt đầu dịch vụ MySQL ..
Bước 7: Đăng nhập vào cơ sở dữ liệu ..

Làm cách nào để tìm mật khẩu gốc mysql trong centos 7?

Cách truy xuất mật khẩu gốc MySQL..
Đăng nhập dưới dạng root vào máy chủ của bạn thông qua SSH [ví dụ: putty/terminal/bash].Ngoài ra, chạy các lệnh theo sau SU hoặc sudo với tư cách là người dùng gốc.....
Điều hướng đến /etc /mysql /cd /etc /mysql ..
Xem tệp của tôi.CNF bằng cách sử dụng lệnh CAT hoặc sử dụng bất kỳ phần mềm chỉnh sửa văn bản nào [VI/VIM/Nano] ..

Làm cách nào để đặt lại mật khẩu gốc mysql?

Trong máy khách MySQL, hãy yêu cầu máy chủ tải lại các bảng cấp để các câu lệnh quản lý tài khoản hoạt động: MySQL> Đặc quyền xả; sau đó thay đổi mật khẩu tài khoản '@' 'localhost'.Thay thế mật khẩu bằng mật khẩu mà bạn muốn sử dụng.mysql> FLUSH PRIVILEGES; Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use.

Làm cách nào để đặt lại mật khẩu gốc trong centos?

Cách khôi phục mật khẩu gốc của bạn-từng bước..
Làm gián đoạn đếm ngược bộ tải khởi động bằng cách nhấn bất kỳ phím nào.....
Nhấn vào E E để chọn mục đó.....
Trong dòng lệnh kernel, di chuyển con trỏ đến đường bắt đầu bằng Linux16 ..
Nhấn phím end end end để di chuyển con trỏ đến cuối của nó.....
Sau đó nhấn vào CTRL+X, để lưu những thay đổi đó ..

Bài Viết Liên Quan

Chủ Đề