MySQL授权密码

mysql> crate databases school charcter set utf8;
Query OK, 1 row affected, 1 warning (0.00 sec)

2.在school数据库中创建Student和Score表

MySQL授权密码_第1张图片MySQL授权密码_第2张图片

mysql> use school
Database changed
mysql> create table student
    -> 
    -> (id int(10) primary key auto_increment,
    -> name varchar(20)not null,
    -> sex varchar(4),
    -> birth year,
    -> department varchar(20)not null,
    -> address varchar(50)
    -> );
Query OK, 0 rows affected (0.01 sec)
 
mysql> desc student;
+------------+-------------+------+-----+---------+----------------+
| Field      | Type        | Null | Key | Default | Extra          |
+------------+-------------+------+-----+---------+----------------+
| id         | int(10)     | NO   | PRI | NULL    | auto_increment |
| name       | varchar(20) | NO   |     | NULL    |                |
| sex        | varchar(4)  | YES  |     | NULL    |                |
| birth      | year(4)     | YES  |     | NULL    |                |
| department | varchar(20) | NO   |     | NULL    |                |
| address    | varchar(50) | YES  |     | NULL    |                |
+------------+-------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
mysql> create table score(
    -> id int(10) primary key auto_increment,
    -> Stu_id int(10) not null,
    -> C_name varchar(20),
    -> Grade int(10)
    -> );
Query OK, 0 rows affected (0.01 sec)
 
mysql> desc score;
+--------+-------------+------+-----+---------+----------------+
| Field  | Type        | Null | Key | Default | Extra          |
+--------+-------------+------+-----+---------+----------------+
| id     | int(10)     | NO   | PRI | NULL    | auto_increment |
| Stu_id | int(10)     | NO   |     | NULL    |                |
| C_name | varchar(20) | YES  |     | NULL    |                |
| Grade  | int(10)     | YES  |     | NULL    |                |
+--------+-------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

3.授权用户tom,密码Mysql@123,能够从任何地方登录并管理数据库schoo。

mysql> create user tom@'localhost' identified by 'Mysql@123';
Query OK, 0 rows affected (0.00 sec)
 
mysql> 

你可能感兴趣的:(mysql,数据库)