Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of configuring Mysql Database safely by Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the method of Linux security configuration Mysql database, which has a certain reference value, friends who need can refer to it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

1. Change the password of the mysql administrator account root

Method 1: shell command

Mysqladmin-u root-p password "123"

two。 View the table where the password is stored

Method 2: mysql database command

Mysql > use mysql;mysql > update user set password=password ('123') where user='root' and host='localhost';mysql > FLUSH PRIVILEGES; # Refresh

Test whether the password modification is successful

2. Modify the mysql administrator account root

Update mysql.user set user= "admin" where user= "root" and host= "localhost"; flush privileges

test

3. Mysql administrator root account password forgotten

Method 1:

Killall-TERM mysqldmysqld_safe-- skip-grant-tables & mysql-u admin mysql > update user set password=password ('123456') where user='admin' and host='localhost';mysql > FLUSH PRIVILEGES;MySQL > quit

Restart MySQL and log in with the new password

Set a new password and refresh the changes

Test, restart the mysqld service to log in with the new password

Method 2:

Modify / etc/my.cnf

Add: under [Mysqld]:

Skip-grant-tables

Restart the MySQL service

Mysql-u rootmysql > update user set password=password ('123') where user='admin' and host='localhost';mysql > FLUSH PRIVILEGES;MySQL > quit

Modify / etc/my.cnf delete skip-grant-tables

Restart MySQL and log in with the new password

test

Modify / etc/my.cnf delete skip-grant-tables

Restart MySQL and log in with the new password

Fourth, create database users

Method 1:

INSERT INTO user (host, user, password, select_priv, insert_priv, update_priv) VALUES ('localhost',' yuzly', PASSWORD ('yuzly'),' Y','Y','Y')

Method 2:

CREATE USER 'user1'@'localhost' IDENTIFIED BY' yuzly'

Method 3: create a database user through new user authorization

5. Authority management

Local permissions

1. Create a zhang user, give only select permissions, and then view permissions

two。 Log in to the zhang user, mysql-uzhang-pyuzly test, and create a table. The following figure shows that it is rejected. The current account does not have create permission.

3. Log in to the administrator account and add create permissions to the Zhang San account

4. Log in to the zhangsan account again to test whether you have create permission. The following figure shows that you have create permission.

5. Insert a piece of data. The following figure indicates that there is no insert permission.

6. Log in to the administrator account and add insert permissions to the Zhang San account

7. Log in to the zhangsan account again to test whether you have insert permission. The following figure shows that you have insert permission.

8. The new user created does not have any permissions by default. You can see in the following figure that the created user does not have any permissions by default.

9. Log in to the newly created user mysql-uabcd-pyuzly and test. The following figure shows that abcd does not have permissions such as select. You can only view things that come with the mysql system with show, but you cannot see databases created by other users.

Remote connection permissions

1. Create an account and grant remote login permission

Grant all on userdb.* to 'abc'@'10.10.10.200' identified by' yuzly';flush privileges

two。 Test, login authentication from another Linux Mysql client

3. As you can see in the following figure, the abc user has any permissions on the userdb database, but no permissions on other databases, such as mysql.user

4. Remote connection is limited to one network segment

5. test

Revoke the authority

Revoke all on userdb.* from 'zhangsan'@'localhost'

Test whether revoking the authority of the zhangsan account is effective.

Delete an account

Delete from mysql.user where user= "aaa" and host= "localhost"

Thank you for reading this article carefully. I hope it will be helpful for everyone to share the methods and contents of Linux security configuration Mysql database. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report