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 ';