MySQL创建数据库相关命令
转载请注明来源-作者@loongshawn:http://blog.csdn.net/loongshawn/article/details/73634525,建议读者阅读原文,确保获得完整的信息
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 41892Server 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 licenseType '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.补充说明
若文中有不详尽之处,请留言或自行去百度搜索。欢迎讨论。
作者:loongshawn
来源链接:https://blog.csdn.net/loongshawn/article/details/73634525
版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。
2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。