MySQL授权密码

2023-12-13 16:33:05
mysql> crate databases school charcter set utf8;
Query OK, 1 row affected, 1 warning (0.00 sec)

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

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> 

文章来源:https://blog.csdn.net/m0_69550154/article/details/134824198
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。