将MySQL服务器连接到NetBeans [英] connecting MySQL server to NetBeans
问题描述
我试图在Netbeans中连接MySQL数据库,并在第一步连接数据库时遇到了麻烦.我的数据库在控制台上运行正常-尝试使用命令mysqladmin -u root -p ping 它说mysql id还活着.我什至从控制台创建了数据库. 现在,当我在Netbeans中注册
I am trying to connect MySQL database in Netbeans and stuck at the very first step- connecting the database. My Database is working fine on the console - tried command mysqladmin -u root -p ping and it says mysql id is alive. I have even created database from console. Now when i register it in Netbeans
Server Host Name:localhost
Server Port:3306
Admin user : root
Admin password :<the password which works on console>
和管理属性:
Path to admin tool: C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqladmin.exe
Argument : <blank>
Path to start command:C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe
Argument : --console <as suggested in http://forums.netbeans.org/topic12767.html>
Path to stop command:C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqladmin.exe
Argument : -u root shutdown
但我仍然收到消息: 位于localhost:3306 [root](断开连接)的MySQL Server"
but i still get message:- "MySQL Server at localhost:3306 [root] (disconnected)"
如果我右键单击并选择开始"或连接",则会在任务栏中显示消息- 正在等待MYSQL Server启动... 无限的时间.
if i right click and select "start" or "connect" i get the message in taskbar - Waiting for MYSQL Server to start... for an infinite time.
任何帮助我在这里做错了吗?
Any help what am i doing wrong here???
推荐答案
请遵循以下两个步骤:
使用服务标签执行以下步骤:
Follow these steps using the Services Tab:
- 右键单击数据库
- 创建新的连接
自定义新连接,如下所示:
Customize the New COnnection as follows:
- 连接器名称:MYSQL(连接器/J驱动程序)
- 主机:
localhost
- 端口:
3306
- 数据库:
mysql
(mysql是默认值或输入您的数据库名称) - 用户名:输入数据库用户名
- 密码:输入数据库密码
- JDBC URL:
jdbc:mysql://localhost:3306/mysql
- 点击完成按钮
- Connector Name: MYSQL (Connector/J Driver)
- Host:
localhost
- Port:
3306
- Database:
mysql
( mysql is the default or enter your database name) - Username: enter your database username
- Password: enter your database password
- JDBC URL:
jdbc:mysql://localhost:3306/mysql
- CLick Finish button
注意事项:删除URL中的?zeroDateTimeBehaviour=convertToNull
部分.
您应该看到数据库名称,而不是URL中的mysql
NB: DELETE the ?zeroDateTimeBehaviour=convertToNull
part in the URL.
Instead of mysql
in the URL, you should see your database name)
- 右键单击
MySQL Server at localhost:3306:[username](...)
- 从快捷菜单中选择属性...
- Right click on
MySQL Server at localhost:3306:[username](...)
- Select Properties... from the shortcut menu
在"MySQL服务器属性" 对话框中,选择管理员属性" 标签 在指定的文本框中输入以下内容:
In the "MySQL Server Properties" dialog select the "Admin Properties" tab Enter the following in the textboxes specified:
对于Linux用户:
- 启动命令的路径:
/usr/bin/mysql
- 参数:
/etc/init.d/mysql start
- 停止命令的路径:
/usr/bin/mysql
- 参数:
/etc/init.d/mysql stop
- Path to start command:
/usr/bin/mysql
- Arguments:
/etc/init.d/mysql start
- Path to Stop command:
/usr/bin/mysql
- Arguments:
/etc/init.d/mysql stop
对于MS Windows用户:
注意:可选:
在管理工具的路径/URL"字段中,键入或浏览到MySQL管理应用程序的位置,例如MySQL Admin Tool,PhpMyAdmin或其他基于Web的管理工具.
In the Path/URL to admin tool field, type or browse to the location of your MySQL Administration application such as the MySQL Admin Tool, PhpMyAdmin, or other web-based administration tools.
注意:mysqladmin是在MySQL安装目录的bin文件夹中找到的MySQL管理工具.它是一个命令行工具,不适合与IDE一起使用.
Note: mysqladmin is the MySQL admin tool found in the bin folder of the MySQL installation directory. It is a command-line tool and not ideal for use with the IDE.
在此示例中,我们将使用MySQL Workbench.如果您有MySQL工作台,请使用安装路径和MySQL路径.
We will use MySQL Workbench in this example. Please use the path of your installation if you have MySQL workbench and the path to MySQL.
- 管理工具的路径/URL:
C:\Program Files\MySQL\MySQL Workbench CE 5.2.47\MySQLWorkbench.exe
- 参数:(保留空白)
- 启动命令的路径:
C:\mysql\bin\mysqld
(或C:\mysql\bin\mysqld.exe
) - 参数:(保留空白)
- 停止命令的路径:
C:\mysql\bin\mysqladmin
(或C:\mysql\bin\mysqladmin.exe
) - 参数:
-u root shutdown
(尝试-u root stop
)
- Path/URL to admin tool:
C:\Program Files\MySQL\MySQL Workbench CE 5.2.47\MySQLWorkbench.exe
- Arguments: (Leave blank)
- Path to start command:
C:\mysql\bin\mysqld
(ORC:\mysql\bin\mysqld.exe
) - Arguments: (Leave blank)
- Path to Stop command:
C:\mysql\bin\mysqladmin
(ORC:\mysql\bin\mysqladmin.exe
) - Arguments:
-u root shutdown
(Try-u root stop
)
Windows用户的MySQL bin文件夹位置的可能范例:
-
C:\mysql\bin
-
C:\Program Files\MySQL\MySQL Server 5.1\bin\
- 安装文件夹:
~\xampp\mysql\bin
C:\mysql\bin
C:\Program Files\MySQL\MySQL Server 5.1\bin\
- Installation Folder:
~\xampp\mysql\bin
这篇关于将MySQL服务器连接到NetBeans的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!