1.创建数据库school,字符集为utf8
mysql> create database school character set utf8;
2.在school数据库中创建Student和Score表
mysql> create table school.student(
-> Id int(10) primary key,
-> Stu_id int(10) not null,
-> C_name varchar(20),
-> Grade int(10)
-> );
Query OK, 0 rows affected, 3 warnings (0.03 sec)
mysql> create table school.score(
-> Id int(10) primary key,
-> Name varchar(20) not null,
-> Sex varchar(4),
-> Birth year,
-> Department varchar(20) not null,
-> Address varchar(50)
-> );
Query OK, 0 rows affected, 1 warning (0.03 sec)
3.授权用户tom,密码Mysql@123,能够从任何地方登录并管理数据库school
mysql> CREATE USER 'tom'@'%' IDENTIFIED BY 'Mysql@123';
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT ALL PRIVILEGES ON school.* TO 'tom'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
4.使用mysql客户端登录服务器,重置root密码
mysql> alter user root@localhost identified by'MyNewPassword!123';
Query OK, 0 rows affected (0.01 sec)