MySQL 在 DataGrip JetBrains 中创建新数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35464187/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Creating new database in DataGrip JetBrains
提问by Abduhafiz
Anybody know how to create new database in DataGrip(database IDE from JetBrains)? Could not find in DataGrip Help page.
有人知道如何在DataGrip(JetBrains 的数据库 IDE)中创建新数据库吗?在DataGrip 帮助页面中找不到。
回答by moscas
回答by USER_1
You first define the database. File --> Data Sources and Drivers --> Click on the green '+' in the top left corner to select the database type. And then fill in all the settings in the 'General' tab.
首先定义数据库。文件 --> 数据源和驱动程序 --> 点击左上角的绿色“+”选择数据库类型。然后填写“常规”选项卡中的所有设置。
For example for PostgreSQL:
以 PostgreSQL 为例:
Host: localhost
主机:本地主机
Database: postgres
数据库:postgres
User: postgres
用户: postgres
Password: password
密码:密码
Once you are set up, Ctrl+Shift+F10 to open the console and you can type your SQL statements, e.g.:
设置完成后,Ctrl+Shift+F10 打开控制台,您可以键入 SQL 语句,例如:
CREATE DATABASE my_database TEMPLATE template1
回答by HumanJHawkins
I don't believe the existing answers cover MySQL... In MySQL, creating a new schema is equivalent to creating a new database. For this case, contextual-click (usually right-click) on your connection in the navigation tree and choose New | Schema. Give it a name and 'Execute in database".
我不相信现有的答案涵盖 MySQL ......在 MySQL 中,创建一个新模式相当于创建一个新数据库。在这种情况下,上下文单击(通常是右键单击)导航树中的连接并选择新建 | 架构。给它一个名字和“在数据库中执行”。
The name of this schema will show up in the navigation tree and you can then add tables, data, etc.
此模式的名称将显示在导航树中,然后您可以添加表、数据等。
回答by Stefan Musarra
The tricky part of creating a new database, is that you have to do it using a DataGrip "Data Source" where are are connected as a user that has the priviledge to create a database, which is generally the "admin" user that you added when you first installed Postgres which is connected to the main "postgres" database.
创建新数据库的棘手部分是,您必须使用 DataGrip“数据源”来执行此操作,其中以具有创建数据库权限的用户身份连接,通常是您添加的“管理员”用户当您第一次安装连接到主“postgres”数据库的 Postgres 时。
I like to keep track of all the commands I have run by attaching a new directory (File Menu | Attach Directory) and creating new files with descriptive names, such as "create_my_test_db.sql" and enter the sql to create the database:
我喜欢通过附加新目录(文件菜单 | 附加目录)并创建具有描述性名称的新文件(例如“create_my_test_db.sql”)来跟踪我运行的所有命令,然后输入 sql 以创建数据库:
create database my_test_db;
When you want to execute this code, make sure that you are using the correct "console". DataGrip has a drop-down menu in the upper-right corner above your file menu, so make sure you have selected "postgres@localhost", since this is the user Data Source that has privileges to create a new database.
当您要执行此代码时,请确保您使用的是正确的“控制台”。DataGrip 在文件菜单上方的右上角有一个下拉菜单,因此请确保您选择了“postgres@localhost”,因为这是有权创建新数据库的用户数据源。
Similarly, to create a new user for this data base, create a new sql file "create_my_test_db_user.sql"
同样,要为这个数据库创建一个新用户,创建一个新的sql文件“create_my_test_db_user.sql”
create user my_test_db_user with encrypted password 'keyboard_cat';
grant all privileges on my_test_db to my_test_db_user;
Then you can create a new Data Source, and set the properties to host = localhost, user = my_test_db_user, and password = keyboard_cat.
然后您可以创建一个新的数据源,并将属性设置为 host = localhost、user = my_test_db_user 和 password = keyboard_cat。
回答by Stefan Musarra
Go to the name of your connection (eg: cat-app@localhost) ,right-click and select Schema. Creating a Schema and Database are same in Mysql.
转到您的连接名称(例如:cat-app@localhost),右键单击并选择架构。在 Mysql 中创建 Schema 和数据库是相同的。