写错数据类型如何去修改呢!如何查看已存在的用户授权信息!

简单的修改MySQL表中的数据类型。
如何查看已存在的用户授权信息。

简单的修改MySQL表中的数据类型

#替换age的数据类型为int2)

mysql> desc chengji;
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| xuehao  | int(6)      | NO   |     | NULL    |       |
| name    | varchar(10) | YES  |     | NULL    |       |
| age     | int(6)      | YES  |     | NULL    |       |
| address | varchar(10) | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> alter table chengji modify column age int(2);   
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc chengji;
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| xuehao  | int(6)      | NO   |     | NULL    |       |
| name    | varchar(10) | YES  |     | NULL    |       |
| age     | int(2)      | YES  |     | NULL    |       |
| address | varchar(10) | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

在test表中新增name列,数据类型为varchar(10)

alter table test add context_time datetime not NULL;
mysql> create table aa (id int(10) not null primary key);
Query OK, 0 rows affected (0.07 sec)

mysql> desc aa;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id    | int(10) | NO   | PRI | NULL    |       |
+-------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)

mysql> alter table aa add name varchar(10);
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc aa;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(10)     | NO   | PRI | NULL    |       |
| name  | varchar(10) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

Mysql将某个字段修改为null(从不允许为空not null修改为 null)

Mysql将某个字段修改为null(从不允许为空not null修改为 null)

alter table 表 modify 字段类型

mysql> update tom set address=‘hangzhou’ where id=1;

如何授权用户登录

mysql> grant all privileges on *.* to 'mha'@'192.168.158.10' identified by 'manager';
Query OK, 0 rows affected (0.00 sec)

如何查看已存在的用户授权信息,存放在mysql库里面的user表中

mysql>  select host,user,password from mysql.user;
+----------------+-------------+-------------------------------------------+
| host           | user        | password                                  |
+----------------+-------------+-------------------------------------------+
| localhost      | root        |                                           |
| client1        | root        |                                           |
| 127.0.0.1      | root        |                                           |
| ::1            | root        |                                           |
| localhost      |             |                                           |
| client1        |             |                                           |
| 192.168.158.%  | myslave     | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 |
| 192.168.158.%  | mha         | *7D2ABFF56C15D67445082FBB4ACD2DCD26C0ED57 |
| %              | mha@server2 | *7D2ABFF56C15D67445082FBB4ACD2DCD26C0ED57 |
| server2        | mha         | *7D2ABFF56C15D67445082FBB4ACD2DCD26C0ED57 |
| 192.168.158.10 | mha         | *7D2ABFF56C15D67445082FBB4ACD2DCD26C0ED57 |
| 192.168.158.30 | mha         | *7D2ABFF56C15D67445082FBB4ACD2DCD26C0ED57 |
| 192.168.158.20 | mha         | *7D2ABFF56C15D67445082FBB4ACD2DCD26C0ED57 |
+----------------+-------------+-------------------------------------------+
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值