Make a new MySQL installation safer _ MySQL

Source: Internet
Author: User
Make the installation of a new MySQL more secure after you install a new MySQL server, you need to specify a directory for the MySQL root user (no password by default ), otherwise, if you forget this, you will put your MySQL in a very insecure state (at least for a period of time ).

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

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

You can connect to the local host as a root without specifying a password. Root users have all permissions (including management permissions) and can do anything. (By the way, MySQL super users have the same name as Unix super users, and they have nothing to do with each other .)
Anonymous access authorized users can connect to a database named test and any database named test _ locally. Anonymous users can do anything to the database, but have no management permission.
Multi-server connection from the local host is allowed, regardless of whether the connected user uses a localhost host name or a real host name. For example:

% Mysql-h localhost test

% Mysql-h pit.snke.net test

The fact that you use root to connect to MySQL does not even specify a password means that the initial installation is not secure. Therefore, as an administrator, the first thing you need to do is to set the root password, then, based on how you set the password, you can also tell the server to reload the authorization table because it knows the change. (When the server starts, it reloads the table to the memory and may not know that you have modified them .)

For MySQL 3.22 and later versions, you can use mysqladmin to set a password:

% Mysqladmin-u root password yourpassword

For any MySQL version, 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 earlier MySQL version, use mysql and UPDATE.

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

% Mysqladmin-u root status

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

% Mysqladmin-u root reload

After you set the root password (and if you need to reload the authorization table), you will need to specify the password at any time when connecting to the server as root.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.