CentOS MySQL user and database management manual

Source: Internet
Author: User

CentOS MySQL user and database management manual

1. Maintenance of the root user password:

After MySQL is installed, MySQL automatically provides a root user without a password. To ensure security, set the password for the root user:

# Mysqladmin-u root password 123 (123 is the password, which can also be written as '200' or "123 ″);

After the password is set, you cannot directly enter mysql when logging on. You must follow these parameters:

[Root @ localhost ~] # Mysql-u root-p (-u followed by the user name to log on,-p prompts you to log on with a password)

Enter password: (Enter the password)

Change Password:

[Root @ localhost ~] # Mysqladmin-u root-p password 123456 (password is followed by the new password to be updated)

Enter password: (Enter the original password and press Enter)

2. add and delete other users:

Log on as a root user. There is a mysql. user table in mysql that stores the information tables of all users in MySQL. Therefore, you can directly add and delete records of this table to add and delete users;

Before adding a user, you can add a database. You can also add a database later:

Create database mydata;

1. Add a user (in two forms ):

A. mysql> grant all on *. * to bkjia @ "%" identified by "123 ″;

Mysql> flush privileges; (refresh the system permission table)

(The execution will be completed in mysql. insert a record to the user table. "all" indicates all permissions (including adding, deleting, modifying, and querying permissions ),*. * Indicates all databases. bkjia indicates the username added, 123 indicates the password, and % indicates all matched hosts. The preceding information can be specified as shown in Figure

Grant select, update on db. * to bkjia @ localhost identified by '000000 ″;)

B. directly add a record to mysql. user

Mysql> insert into mysql. user (Host, User, Password) values ("localhost", "yusuhan", password ("123 ″));

Mysql> flush privileges;

In this way, a user named bkjia with the password 123 (the password is encrypted) is created, but the user does not have the permission because only three fields are added, you can also add permissions through grant:

Mysql> grant all on *. * to bkjia @ localhost identified by '000000 ″;

Mysql> flush privileges; (refresh the system permission table)

After adding a user, if you want to remotely log on to MySQL, you must keep up with the Host Ip address as follows:

[Root @ localhost ~] # Mysql-u bkjia-p-h 192.168.59.123

Enter password: (Enter the password)

2. delete a user:

Mysql> delete from mysql. user where user = 'bkjia ';

Mysql> flush privileges; (refresh the system permission table)

The password of other users is the same as that of the root user. Here, a flush privileges must be created after the addition or deletion operations. This will take effect, especially if the user is not deleted, you can also log on to the deleted user. All of the preceding operations are performed under the MySQL root User. To ensure MySQL security, you must specify the corresponding permissions.

This article permanently updates the link address:

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.