mysql 創建數據庫_MySQL創建數據庫相關命令

1.數據庫創建

第一步:登錄數據庫,輸入命令sudo mysql -u root -p[loongshawn@e100069197189.zmf /home/loongshawn]

$sudo mysql -u root -p

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

[loongshawn@e100069197189.zmf /home/loongshawn]

$sudo mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 41892

Server version: 5.6.21 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

第二步:登錄數據庫,查看當前已存在數據庫,並創建創建數據庫。mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| data_loong_1 |

| data_loong_2 |

| mapdata_1 |

| mapdata_2 |

| mysql |

| performance_schema |

| rong_1 |

| rong_2 |

| test |

+--------------------+

10 rows in set (0.02 sec)

創建數據庫命令create database knowledge_base_daily;mysql> create database knowledge_base_daily;

Query OK, 1 row affected (0.00 sec)

2.分配權限

給數據庫分配用戶、分配權限,由於庫中已存在用戶,就不再新建用戶及權限了,然后manager這個用戶擁有數據庫的所有權限;mysql> grant all privileges on knowledge_base_daily.* to 'manager'@'%' identified by '12345678';

Query OK, 0 rows affected (0.08 sec)

mysql> grant all privileges on knowledge_base_publish.* to 'manager'@'%' identified by '12345678';

Query OK, 0 rows affected (0.00 sec)

mysql>

如果需要給具體用戶分配數據庫具體數據表的權限,使用以下命令,如manager擁有table的update權限。grant update on knowledge_base_publish.table to 'manager'@'%';

補充說明如何新建用戶,通過命令:create user 'loongshawn'@'%' identified by '12345678';

Query OK, 0 rows affected (0.08 sec)

3.補充說明

若文中有不詳盡之處,請留言或自行去百度搜索。歡迎討論。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值