MySQL User creation and authorization

Source: Internet
Author: User

Environment

MySQL 5.1 + command line tools

Problem

MySQL User creation and authorization

Solve

1. Log in as root to create a new user

C:\users\wentasy>mysql-uroot-p  
      
mysql> CREATE USER Music identified by ' music ';

2. Create database as root user login

Create DATABASE music default CharSet UTF8;  
    CREATE TABLE Tb_user (tb_user_id int (one) primary key auto_increment, Tb_user_account varchar () NOT NULL, Tb_user_password varchar NOT NULL, Tb_user_nick varchar NOT NULL, tb_user_name varchar (a) not n ull, Tb_user_gender bit (1), Tb_user_phone varchar (), tb_user_email varchar (), check (tb_user_g  
      
Ender in (' 0 ', ' 1 '));  
    CREATE TABLE tb_playlist (tb_playlist_id int (one) primary key auto_increment, tb_user_id Int (one) not NULL, Tb_playlist_title varchar (255) NOT NULL, constraint fk_tb_user_id foreign key (tb_user_id) references Tb_user (TB  
      
_user_id));   
    CREATE TABLE Tb_records (tb_records_id int (one) primary key auto_increment, tb_playlist_id Int (one) not NULL, Tb_records_name varchar () NOT NULL, constraint fk_tb_playlist_id foreign key (tb_playlist_id) references Tb_ Playlist (tb_playlist_id));

3. Log in as root user authorization

Mysql> GRANT all privileges in music.* to 

Music@localhost identified by ' music ';

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.