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

Make a new MySQL installation more secure (transfer)

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Make a new MySQL installation more secure (transfer) [@ more@] after you install a new MySQL server yourself, you need to specify a directory for MySQL root users (no password by default), otherwise if you forget this, you will put your MySQL in an extremely insecure state (at least for a while).

On Unix (Linux), after installing MySQL according to the instructions in the manual, you must run the mysql_install_db script to create the mysql database containing the authorization table and initial permissions. On Windows, run the Setup program in the distribution to initialize the data catalog and mysql database. Assume that the server is also running.

When you first install MySQL on your machine, the authorization table in the mysql database is initialized as follows:

You can connect with root from the local host (localhost) without specifying a password. The root user has all privileges, including administrative privileges, and can do anything. (by the way, MySQL superusers and Unix superusers have the same name, and they have nothing to do with each other. )

Anonymous access is granted to users to connect locally to a database with the name test and any database whose name starts with test_. Anonymous users can do anything to the database, but do not have administrative privileges.

Multiple server connections from the local host are allowed, regardless of whether the connected user uses a localhost hostname or a real hostname. Such as:

% mysql-h localhost test

% mysql-h pit.snake.net test

The fact that you use root to connect to MySQL or even not specify a password just means that the initial installation is not secure, so as an administrator, the first thing you should do is to set the root password, and then depending on the method you use to set the password, you can also tell the server that the overload authorization table is aware of this change. When the server starts, it reloads the tables into memory and may not know that you have modified them. )

For MySQL 3.22 and above, you can set the password with mysqladmin:

% mysqladmin-u root password yourpassword

For any version of MySQL, you can use the mysql program and directly modify the user authorization table in the mysql database:

% mysql-u root mysql

Mysql > UPDATE user SET password=PASSWORD ("yourpassword") WHERE User= "root"

If you have an older version of MySQL, use mysql and UPDATE.

After you have set the password, check whether you need to tell the server to reload the authorization table by running the following command:

% mysqladmin-u root status

If the server still allows you to connect to the server with root without specifying a password, reload the authorization table:

% mysqladmin-u root reload

After you have set the password for root (and if you need to overload the authorization table), you will need to specify the password whenever you connect to the server with root.

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

Database

Wechat

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

12
Report