Create a user in mysql, authorize the user, delete the user, and change the password.

Source: Internet
Author: User

Mysql has several graphic management software, such as mysql-front and phpadmin, which are easy to use and will not be introduced here. In addition, eclipse has a database management plug-in called, which can be used to manage various commonly used databases in graphs.

The following describes common SQL operations:

You are familiar with creating database tables and querying insert and delete records. These operations are also important for users and passwords, especially when using databases.

Log on to MYSQL
> Mysql-u root-p
> Password

Create user
Mysql> insert into mysql. user (Host, User, Password, ssl_cipher, x509_issuer, x509_sub
Ject) values ("localhost", "fred", password ("love "),'','','');

The created user name is fred and the password is love.

Create a database (test)
Mysql> create database test;
Grant all permissions of the test database to user fred
> Grant all privileges on test. * to fred @ localhost identified by 'love ';
Refresh system permission list
Mysql> flush privileges;

If you want to assign some permissions to a user, you can write as follows:
Mysql> grant select, update on phplampDB. * to fred @ localhost identified by 'love ';
Refresh the system permission table.
Mysql> flush privileges;

Modify the password of a specified user.
> Mysql-u root-p
> Password
Mysql> update mysql. user set password = password ('new password') where User = "fred" and Host = "localhost ";
Mysql> flush privileges;

Delete a user.
> Mysql-u root-p
> Password
Mysql> delete from user WHERE User = "fred" and Host = "localhost ";
Mysql> flush privileges;
Delete a user's database
Mysql> drop database test;

Other useful operations:

List all databases

Mysql> show database;

Switch Database

Mysql> use 'database name ';

List all tables

Mysql> show tables;

Show data table structure

Mysql> describe table name;

Delete databases and data tables

Mysql> drop database name;
Mysql> drop table data table name;

 

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.