mysql> create database school;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| db1 |
| information_schema |
| myemployees |
| mysql |
| performance_schema |
| school |
| score |
| student |
| sys |
| worker |
| 工作日期表 |
+--------------------+
11 rows in set (0.00 sec)
mysql> exit
2、在school数据库中创建Student和Score表素材看图
创建student表
mysql> use school
Database changed
create table student (id int(10) primary key autto_increment, name varchar(20)not null, sex varchar(4),, birth year, department varchar(20)not null, addressvarchar(50) );
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> desc student;
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| name | varchar(20) | NO | | NULL | |
| sex | varchar(4) | YES | | NULL | |
| birth | year | 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 aut_o_increment, Stu_id int(10) not null, C_name varchar(2
20), Grade int(10) );
Query OK, 0 rows affected, 3 warnings (0.01 sec)
mysql> desc score;
+--------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+----------------+
| id | int | NO | PRI | NULL | auto_increment |
| Stu_id | int | NO | | NULL | |
| C_name | varchar(20) | YES | | NULL | |
| Grade | int | YES | | NULL | |
+--------+-------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)
3、授权用户tom,密码Mysql@123,能够从任何地方登录并管理数据库school。
mysql> create user 'tom'@'%'identified by 'mysql';
mysql> grant all privileges on school to 'tom'@'%';
4、使用mysql客户端登录服务器,重置root密码.
[root ~]# mysqld —user=mysql —skip–grant–tables
[root my.cnf.d]# mysql – 在另一个会话中直接输入MySQL登录,此时无密码
mysql> flush privileges;刷新权限表
mysql> alter user root identified by’Yyj123456!’;
原文地址:https://blog.csdn.net/qq_44997937/article/details/134741899
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_26632.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。