MYSQL new user and database actual steps

Source: Internet
Author: User

The following article is mainly about the creation of MySQL new user, the actual steps to create a new database, and how users can authorize and delete the user's actual operation, as well as the actual operation to modify the password, the following is the main content of the body of the creation.

1.MYSQL new user.

Log in to MySQL

@>mysql-u root-p

@> Password

Create user

    1. MySQL> mysql> Insert into Mysql.user (host,user,password,ssl_cipher,x509_issuer,x509_sub
    2. ject) VALUES ("localhost", "pppadmin", Password ("passwd"), ', ', ', ');

This creates a user named: Phplamp with a password of: 1234.

Then log in.

mysql>exit;

@>mysql-u phplamp-p

@> Enter password

Mysql> Login Successful

2. Authorize the user.

Log in to MySQL (with root privileges). I am logged in as root.

@>mysql-u root-p

@> Password

First create a database for MySQL new user (phplampdb)

    1. MySQL>create database phplampdb;

Authorizes the Phplamp user to have all the permissions of the Phplamp database.

    1. >grant all privileges in phplampdb.* to [e-mail protected] identified by ' 1234 ';

Refresh System Permissions Table

    1. MySQL>flush privileges;

Mysql> Other operations

/*

If you want to specify partial permissions to a user, you can write:

    1. MySQL>grant select,update on phplampdb.* to [e-mail protected] identified by ' 1234 ';

Refreshes the System permissions table.

    1. MySQL>flush privileges;
    2. */

3. Delete the user.

@>mysql-u root-p

@> Password

    1. MySQL>delete from user WHERE user="Phplamp" and host="localhost";
    2. MySQL>flush privileges;

Delete a user's database

    1. MySQL>drop database phplampdb;

4. Modify the specified user password.

@>mysql-u root-p

@> Password

    1. MySQL>update mysql.user set passwordpassword=password (' New password ') where user="Phplamp" and Host  ="localhost";
    2. MySQL>flush privileges;

5. List all databases

Mysql>show database;

6. Switching the database

Mysql>use ' database name ';

7. List all Tables

Mysql>show tables;

8. Display the data table structure

Mysql>describe table name;

9. Deleting databases and data tables

Mysql>drop database name;

Mysql>drop table Data Sheet name;

MYSQL new user and database actual steps

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.