问题描述
我正在尝试在 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 FilesMySQLMySQL Server 5.6inmysqladmin.exe
Argument : <blank>
Path to start command:C:Program FilesMySQLMySQL Server 5.6inmysqld.exe
Argument : --console <as suggested in http://forums.netbeans.org/topic12767.html>
Path to stop command:C:Program FilesMySQLMySQL Server 5.6inmysqladmin.exe
Argument : -u root shutdown
但我仍然收到消息:-本地主机上的 MySQL 服务器:3306 [root](已断开连接)"
but i still get message:- "MySQL Server at localhost:3306 [root] (disconnected)"
如果我右键单击并选择开始"或连接",我会在任务栏中收到消息 -正在等待 MYSQL 服务器启动...无限的时间.
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???
推荐答案
遵循以下 2 个步骤:
Follow these 2 steps:
使用服务标签执行以下步骤:
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](...)
- 从快捷菜单中选择属性...
在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
对于 MS Windows 用户:
注意:可选:
在管理工具的路径/URL 字段中,输入或浏览到您的 MySQL 管理应用程序的位置,例如 MySQL 管理工具、PhpMyAdmin 或其他基于网络的管理工具.
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 FilesMySQLMySQL Workbench CE 5.2.47MySQLWorkbench.exe
- 参数:(留空)
- 启动命令的路径:
C:mysqlinmysqld
(ORC:mysqlinmysqld.exe
) - 参数:(留空)
- 停止命令的路径:
C:mysqlinmysqladmin
(ORC:mysqlinmysqladmin.exe
) - 参数:
-u root shutdown
(试试-u root stop
)
- Path/URL to admin tool:
C:Program FilesMySQLMySQL Workbench CE 5.2.47MySQLWorkbench.exe
- Arguments: (Leave blank)
- Path to start command:
C:mysqlinmysqld
(ORC:mysqlinmysqld.exe
) - Arguments: (Leave blank)
- Path to Stop command:
C:mysqlinmysqladmin
(ORC:mysqlinmysqladmin.exe
) - Arguments:
-u root shutdown
(Try-u root stop
)
Windows 用户的 MySQL bin 文件夹位置的可能示例:
C:mysqlin
C:Program FilesMySQLMySQL Server 5.1in
- 安装文件夹:
~xamppmysqlin
这篇关于将 MySQL 服务器连接到 NetBeans的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!