将MySQL服务器连接到NetBeans [英] connecting MySQL server to NetBeans

查看:230
本文介绍了将MySQL服务器连接到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:

  1. 右键单击数据库
  2. 创建新的连接

自定义新连接,如下所示:

Customize the New COnnection as follows:

  1. 连接器名称:MYSQL(连接器/J驱动程序)
  2. 主机:localhost
  3. 端口:3306
  4. 数据库:mysql(mysql是默认值或输入您的数据库名称)
  5. 用户名:输入数据库用户名
  6. 密码:输入数据库密码
  7. JDBC URL:jdbc:mysql://localhost:3306/mysql
  8. 点击完成按钮
  1. Connector Name: MYSQL (Connector/J Driver)
  2. Host: localhost
  3. Port: 3306
  4. Database: mysql ( mysql is the default or enter your database name)
  5. Username: enter your database username
  6. Password: enter your database password
  7. JDBC URL: jdbc:mysql://localhost:3306/mysql
  8. 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)


  1. 右键单击MySQL Server at localhost:3306:[username](...)
  2. 从快捷菜单中选择属性...
  1. Right click on MySQL Server at localhost:3306:[username](...)
  2. 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用户:

  1. 启动命令的路径:/usr/bin/mysql
  2. 参数:/etc/init.d/mysql start
  3. 停止命令的路径:/usr/bin/mysql
  4. 参数:/etc/init.d/mysql stop
  1. Path to start command: /usr/bin/mysql
  2. Arguments: /etc/init.d/mysql start
  3. Path to Stop command: /usr/bin/mysql
  4. 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.

  1. 管理工具的路径/URL: C:\Program Files\MySQL\MySQL Workbench CE 5.2.47\MySQLWorkbench.exe
  2. 参数:(保留空白)
  3. 启动命令的路径: C:\mysql\bin\mysqld(或C:\mysql\bin\mysqld.exe)
  4. 参数:(保留空白)
  5. 停止命令的路径:C:\mysql\bin\mysqladmin(或C:\mysql\bin\mysqladmin.exe)
  6. 参数: -u root shutdown(尝试-u root stop)
  1. Path/URL to admin tool: C:\Program Files\MySQL\MySQL Workbench CE 5.2.47\MySQLWorkbench.exe
  2. Arguments: (Leave blank)
  3. Path to start command: C:\mysql\bin\mysqld (OR C:\mysql\bin\mysqld.exe)
  4. Arguments: (Leave blank)
  5. Path to Stop command: C:\mysql\bin\mysqladmin (OR C:\mysql\bin\mysqladmin.exe )
  6. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆