Xóa mysql_secure_installation

Xóa mysql_secure_installation

Cách thay đổi cổng mặc định MySQL 3306 và bảo mật mysql bằng mysql_secure_installation

  • Báo cáo bài viết này

    Bài báo cáo

    Bài báo cáo

    Quay lại Gửi

Piyush Diwakar Click here to view Piyush Diwakar’s profile

Piyush Diwakar

mysql. Mông Cổ. dịch chuyển đỏ. AWS. tiên tri. Sr. DBA tại Paytm Money. Cựu RAKUTEN. Cựu Innoeye

Đã xuất bản ngày 11 tháng 2 năm 2021

+ Theo dõi

Trong hướng dẫn này, tôi sẽ hướng dẫn bạn cách thay đổi cổng mặc định của mysql và mục đích của mysql_secure_installation là gì

Dưới đây là những gì chúng tôi sẽ làm cho mục đích này

  1. Dừng dịch vụ MySQL
  2. Thay đổi cổng trong Tệp cấu hình MySQL
  3. Khởi động lại dịch vụ MySQL
  4. Chạy tập lệnh bảo mật (mysql_secure_installation)
  • Thay đổi mật khẩu cho root
  • Xóa người dùng ẩn danh
  • Không cho phép root đăng nhập từ xa
  • Xóa cơ sở dữ liệu thử nghiệm và truy cập vào nó
  • Tải lại các bảng đặc quyền ngay bây giờ
  • Đăng nhập vào MySQL Shell bằng mật khẩu mới

Bước 1 - Dừng dịch vụ MySQL

Đối với CentOS

[root@DBA-Master ~]# service mysqld stop

cho Ubuntu

[root@DBA-Master ~]# service mysql stop

Bước 2 - Thay đổi cổng trong tệp cấu hình MySQL

Đối với CentOS

[root@DBA-Master ~]#  vi /etc/my.cnf

[mysqld]


port= 4545
datadir= /home/ist/mysql


save and exit

cho Ubuntu

[root@DBA-Master ~]#  vi /etc/mysql/mysql.conf.d/mysqld.cnf

[mysqld]


port=4545
datadir= /home/ist/mysql


save and exit

Bước 3 - Khởi động lại dịch vụ MySQL

Đối với CentOS

[root@DBA-Master ~]# service mysqld start 

cho Ubuntu

[root@DBA-Master ~]# service mysql start 

Bước 4 - Chạy Tập lệnh bảo mật (mysql_secure_installation)

[root@DBA-Master ~]# mysql_secure_installation 


Securing the MySQL server deployment.


Enter password for user root: 


The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.


Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : Y


New password: 


Re-enter new password: 


Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.


Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.




Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.


Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.


By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.




Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...
Success.


 - Removing privileges on test database...
Success.


Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.


Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.


All done! 

[root@DBA-Master ~]# mysql -uroot -p


[root@DBA-Master ~]# service mysql stop
0

Đây là video Thuyết trình Thay đổi Port mặc định và bảo mật mysql bằng mysql_secure_installation trong MySQL

Xóa MySQL hoàn toàn
  1. Mở thiết bị đầu cuối

  2. Sử dụng

    [root@DBA-Master ~]# service mysql stop
    
    6 để sao lưu cơ sở dữ liệu của bạn

  3. Kiểm tra các quy trình MySQL với.

    [root@DBA-Master ~]# service mysql stop
    
    7

  4. Dừng và hủy mọi quy trình MySQL

  5. Phân tích MySQL trên HomeBrew

    [root@DBA-Master ~]# service mysql stop
    
    1
  6. Xóa các tệp

    [root@DBA-Master ~]# service mysql stop
    
    2
  7. Dỡ đăng nhập tự động MySQL trước đó

    [root@DBA-Master ~]# service mysql stop
    
    3
  8. Xóa cấu hình MySQL trước đó

    [root@DBA-Master ~]# service mysql stop
    
    4
  9. Xóa các tùy chọn MySQL trước đó

    [root@DBA-Master ~]# service mysql stop
    
    5
  10. Khởi động lại máy tính của bạn chỉ để đảm bảo mọi quy trình MySQL bị hủy

  11. Hãy thử chạy mysql, nó không hoạt động

Những tài khoản nào có thể bị xóa bằng mysql_secure_installation?

Bạn có thể xóa các tài khoản gốc có thể truy cập từ bên ngoài máy chủ cục bộ . Bạn có thể xóa tài khoản người dùng ẩn danh. Bạn có thể xóa cơ sở dữ liệu thử nghiệm, theo mặc định, người dùng ẩn danh có thể truy cập cơ sở dữ liệu này.

mysql_secure_installation có cần thiết không?

Có. Sẽ tốt hơn nếu bạn chạy lệnh vì nó cung cấp nhiều tùy chọn bảo mật như. Bạn có thể đặt mật khẩu cho tài khoản root. Bạn có thể xóa tài khoản root có thể truy cập từ bên ngoài máy chủ lưu trữ cục bộ.

Cách gỡ cài đặt MySQL

Cách gỡ cài đặt MySQL .
Dành cho người dùng CentOS và RedHat. sudo yum xóa mysql máy chủ mysql
Đối với người dùng Ubuntu và Debian. sudo apt loại bỏ mysql máy chủ mysql
Đối với người dùng Fedora (cũng như đối với nhiều bản phân phối phụ). Sudo dnf xóa mysql máy chủ mysql

Việc gỡ cài đặt MySQL có xóa cơ sở dữ liệu không?

Không, cài đặt lại máy chủ mysql sẽ không xóa các tệp cơ sở dữ liệu của bạn , chỉ xóa các tệp gói của máy chủ mysql. Bạn sẽ có thể truy cập các tệp (cơ sở dữ liệu) của mình sau khi cài đặt lại máy chủ.