Create and authorize a MySQL user

Source: Internet
Author: User

MySQL user creation and authorization environment www.2cto.com MySQL 5.1 + command line tool problem MySQL user creation and authorization solution 1. log on as the root USER to CREATE a new USER [SQL] C: \ Users \ Wentasy> mysql-uroot-p mysql> CREATE USER music IDENTIFIED BY 'music'; 2. log on as the root user to create a database [SQL] create database music default charset utf8; create table tb_user (tb_user_id int (11) primary key auto_increment, tb_user_account varchar (32) not null, tb_user_password varchar (16) not null, tb_user_nick varchar (16) not null, tb_user_name varchar (32) not null, tb_user_gender bit (1), tb_user_phone varchar (16 ), tb_user_email varchar (40), check (tb_user_gender in ('0', '1'); create table tb_playlist (tb_playlist_id int (11) primary key auto_increment, tb_user_id int (11) not null, tb_playlist_title varchar (255) not null, constraint statement foreign key (tb_user_id) references tb_user (tb_user_id); create table tb_records (occurrence int (11) primary key auto_increment, tb_playlist_id int (11) not null, tb_records_name varchar (40) not null, constraint FK_TB_PLAYLIST_ID foreign key (tb_playlist_id) references tb_playlist (tb_playlist_id); 3. GRANT [SQL] mysql> GRANT ALL PRIVILEGES ON music. * TO music @ localhost identified by 'music'; 4. log on to the [SQL] C: \ Users \ Wentasy> mysql-umusic-p Enter password: * *** Welcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 6 Server version: 5.1.43-community MySQL Community Server (GPL) Type 'help; 'or' \ H' for help. type '\ C' to clear the current input statement. mysql> show databases; + -------------------- + | Database | + -------------------- + | information_schema | music | + ------------------ + 2 rows in set (0.00 sec) mysql> use music; database changed mysql> show tables; + ----------------- + | Tables_in_music | + videos + | tb_playlist | tb_records | tb_user | + --------------- + 3 rows in set (0.01 sec) mysql>

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.