A little experience of MySQL management

Source: Internet
Author: User
Tags anonymous documentation mysql in mysql database linux

MySQL database is the first choice for the backend database of small and medium sized web sites, because it is free for non-commercial applications. Web developers can build a "linux+apache+php+mysql" platform, which is one of the most cost-effective and efficient platforms. When developing with MYSQL, MySQL's own documentation is a good reference for beginners. This article is my little experience in using MySQL.

The current general user's development environment is mostly Windows or Linux, users can download the relevant version of the installation, in Windows MySQL in the form of service, before use should ensure that the service has started, do not start the available net start MySQL command start. Linux can be started with the "/etc/rc.d/init.d/mysqld start" command, and notice that the initiator should have administrator privileges.

The newly installed MySQL contains a root account with a blank password and an anonymous account, which is a great security risk, for some important applications we should improve security as far as possible, where the anonymous account deletion, the root account set the password, you can use the following command:

Use MySQL;

Delete from User where user= "";

Update User set Password=password (' NewPassword ') where user= ' root ';

If you want to limit the logon terminals used by the user, you can update the host field for the corresponding user in the users table, restart the database service after making the above changes, and at this point you may be able to log on to the following similar commands:

Mysql-uroot-p;

Mysql-uroot-pnewpassword;

MySQL mydb-uroot-p;

MySQL Mydb-uroot-pnewpassword;

The command parameters above are part of the common parameters, and the details refer to the documentation. The mydb here is the name of the database to log on to.

In the development and practical applications, users should not only use root to connect the database, although the use of root users to test is very convenient, but it will bring significant security risks to the system, but also not conducive to the improvement of management technology. We give the most appropriate database permissions to the users used in an application. A user who only inserts data should not be given permission to delete data. MySQL user management is implemented through the user table, there are two ways to add new users, one is to insert the corresponding data rows in the user table, set the appropriate permissions, and the second is to create a user with some kind of permission through the grant command. One of the common uses of grant is as follows:

Grant all on mydb.* to identified by "password";

Grant usage on *.* to identified by "password";

Grant Select,insert,update on mydb.* to identified by "password";

Grant Update,delete on MyDB. TestTable to identified by "password";

To give this user the ability to manage his or her permissions on the object, add the WITH GRANT option after Grant. For users added with the Insert User table, the password field applies the password function to update the encryption, in case the malicious person steals the password. For those who have not used the user should be given clearance, permissions of the user should be timely recall permissions, recycling permissions can be updated by the user table corresponding fields, you can also use the revoke operation.

Related Article

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.