Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
669 views
in Technique[技术] by (71.8m points)

connecting MySQL server to 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> 

and Admin Properties:

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  

but i still get message:- "MySQL Server at localhost:3306 [root] (disconnected)"

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???

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Follow these 2 steps:

STEP 1 :

Follow these steps using the Services Tab:

  1. Right click on Database
  2. Create new Connection

Customize the New COnnection as follows:

  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

NB: DELETE the ?zeroDateTimeBehaviour=convertToNull part in the URL. Instead of mysql in the URL, you should see your database name)


STEP 2 :

  1. Right click on MySQL Server at localhost:3306:[username](...)
  2. Select Properties... from the shortcut menu

In the "MySQL Server Properties" dialog select the "Admin Properties" tab Enter the following in the textboxes specified:

For Linux users :

  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

For MS Windows users :

NOTE: Optional:

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.

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.

Citations:
https://netbeans.org/kb/docs/ide/mysql.html?print=yes
http://javawebaction.blogspot.com/2013/04/how-to-register-mysql-database-server.html


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. Path/URL to admin tool: C:Program FilesMySQLMySQL Workbench CE 5.2.47MySQLWorkbench.exe
  2. Arguments: (Leave blank)
  3. Path to start command: C:mysqlinmysqld (OR C:mysqlinmysqld.exe)
  4. Arguments: (Leave blank)
  5. Path to Stop command: C:mysqlinmysqladmin (OR C:mysqlinmysqladmin.exe )
  6. Arguments: -u root shutdown (Try -u root stop)

Possible exampes of MySQL bin folder locations for Windows Users:

  • C:mysqlin
  • C:Program FilesMySQLMySQL Server 5.1in
  • Installation Folder: ~xamppmysqlin

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...