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 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
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???
Follow these 2 steps:
STEP 1 :
Follow these steps using the Services Tab:
Right click on Database
Create new Connection
Customize the New COnnection as follows:
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
NB: DELETE the ?zeroDateTimeBehaviour=convertToNull part in the URL.
Instead of mysql in the URL, you should see your database name)
STEP 2 :
Right click on MySQL Server at localhost:3306:[username](...)
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 :
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
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=yeshttp://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.
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 (OR C:\mysql\bin\mysqld.exe)
Arguments: (Leave blank)
Path to Stop command: C:\mysql\bin\mysqladmin (OR C:\mysql\bin\mysqladmin.exe )
Arguments: -u root shutdown (Try -u root stop)
Possible exampes of MySQL bin folder locations for Windows Users:
C:\mysql\bin
C:\Program Files\MySQL\MySQL Server 5.1\bin\
Installation Folder: ~\xampp\mysql\bin
Fist of all make sure your SQL server is running. Actually I'm working on windows and I have installed a nice tool which is called MySQL workbench (you can find it here for almost any platform ).
Thus I just create a new database to test the connection, let's call it stackoverflow, with one table called user.
SET #OLD_UNIQUE_CHECKS=##UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET #OLD_FOREIGN_KEY_CHECKS=##FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET #OLD_SQL_MODE=##SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
DROP SCHEMA IF EXISTS `stackoverflow` ;
CREATE SCHEMA IF NOT EXISTS `stackoverflow` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `stackoverflow` ;
-- -----------------------------------------------------
-- Table `stackoverflow`.`user`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `stackoverflow`.`user` ;
CREATE TABLE IF NOT EXISTS `stackoverflow`.`user` (
`iduser` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(75) NOT NULL,
`email` VARCHAR(150) NOT NULL,
PRIMARY KEY (`iduser`),
UNIQUE INDEX `iduser_UNIQUE` (`iduser` ASC),
UNIQUE INDEX `email_UNIQUE` (`email` ASC))
ENGINE = InnoDB;
SET SQL_MODE=#OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=#OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=#OLD_UNIQUE_CHECKS;
You can reduce important part to
CREATE SCHEMA IF NOT EXISTS `stackoverflow`
CREATE TABLE IF NOT EXISTS `stackoverflow`.`user` (
`iduser` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(75) NOT NULL,
`email` VARCHAR(150) NOT NULL,
PRIMARY KEY (`iduser`),
UNIQUE INDEX `iduser_UNIQUE` (`iduser` ASC),
UNIQUE INDEX `email_UNIQUE` (`email` ASC))
So now I have my brand new stackoverflow database. Let's connect to it throught Netbeans. Launch netbeans and go to the services panel
Now right click on databases: new connection.. Choose MySql connector, they already come packed with netbeans.
Then fill in the gaps the data you need. As shown in the picture add the database name and remove from the connection url the optional parameters as l?zeroDateTimeBehaviour=convertToNull . Use the right user name and password and test the connection.
As you can see connection is successful.
Click FINISH.
You will have your connection successfully working and available under the services.
check the context.xml file in Web Pages -> META-INF, the username="user" must be the same as the database user, in my case was root, that solved the connection error
Hope helps
I just had the same issue with Netbeans 8.2 and trying to connect to mySQL server on a Mac OS machine. The only thing that worked for me was to add the following to the url of the connection string: &serverTimezone=UTC (or if you are connecting via Hibernate.cfg.xml then escape the & as &) Not surprisingly I found the solution on this stack overflow post also:
MySQL JDBC Driver 5.1.33 - Time Zone Issue
Best Regards,
Claudio
in my cases, i found my password in glassfish-recources.xml under WEB-INF
Close NetBeans.
Stop MySQL Server.
Update MySQL (if available)
Start MySQL Server.
Open NetBeans.
If still doesn't connect, download MySQL Connector/J and add mysql-connector-java-[version].jar to your
classpath and also to your Webserver's lib directory. For instance, Tomcat lib path
in XAMPP is
C:\xampp\tomcat\lib.
Then repeat the steps again.
Download XAMPP
Run XAMPP server. Click on Start button in front of MY SQL. Now you can see that color is changed to green. Now, Click on Admin.The new browser window will be open. Copy the link from browser and paste to the Admin properties as shown in below.
Set path in the admin properties of database connection.
Click on OK. Now your database is connected.
enter image description here
NETBEANS
koneksi
dbmSET #OLD_UNIQUE_CHECKS=##UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET #OLD_FOREIGN_KEY_CHECKS=##FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET #OLD_SQL_MODE=##SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
Related
I'm installing MySQL 8 on an Arm EC2 instance and I cannot get it to work with remote connections. Here's the steps I do to install MySQL:
yum -y install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm --nogpgcheck
yum -y install mysql-community-server --nogpgcheck
I then start MySQL with:
systemctl start mysqld
Then I login as root to MySQL and create a sample database with:
CREATE DATABASE gtfs DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
USE gtfs;
CREATE TABLE agency (
agency_id VARCHAR(255) NOT NULL PRIMARY KEY,
agency_name VARCHAR(255),
agency_url VARCHAR(255),
agency_timezone VARCHAR(255),
agency_lang VARCHAR(255)
);
INSERT INTO agency VALUES ('id', 'name', 'url', 'timezone', 'lang');
So now I have a database created. If I try to connect from a client as root I get ER_HOST_NOT_PRIVILEGED. I've followed along here and created a new user with:
CREATE USER 'lambda'#'%' IDENTIFIED BY 'Password1!';
GRANT ALL ON *.* TO 'lambda'#'%';
and tried it out. I first get ER_NOT_SUPPORTED_AUTH_MODE which I can fix with:
UPDATE mysql.user SET plugin='mysql_native_password' WHERE User='lambda';
And then I'm back getting ER_HOST_NOT_PRIVILEGED with my lambda user. I've also added
bind-address=0.0.0.0
to my /etc/my.cnf file and restarted MySQL with systemctl restart mysqld and it still isn't working.
Running mysql -V outputs
mysql Ver 8.0.28 for Linux on aarch64 (MySQL Community Server - GPL)
Any help is massively appreciated. I'm tearing my hair out at this point. I've checked and I have port 3306 open on the EC2 instance. I cannot figure this out.
I have such a problem, I'm trying to do master-slave replication according to this tutorial https://developpaper.com/master-slave-replication-of-mysql-based-on-docker/ .
There is no problem with the building of the image, but there is a problem with running this container. I can't get access to the mysql commands of mysql container in docker, it seems to be built from mysql (image from docker hub), but can not be started.
There are the following files:
Dockerfile:
#Using MySQL image to create a new image
FROM mysql:latest
ENV MYSQL_ROOT_PASSWORD Kohc9hai
COPY start.sh /mysql/start.sh
COPY my.cnf /etc/mysql/my.cnf
COPY init.sql /mysql/init.sql
EXPOSE 6603
CMD ["sh", "/mysql/start.sh"]
init.sql:
--Create data_ Copy database
DROP DATABASE IF EXISTS `data_copy`;
CREATE DATABASE `data_copy` /*!40100 DEFAULT CHARACTER SET utf8mb4 collate utf8mb4_general_ci */;
--Create person table
USE `data_copy`;
DROP TABLE IF EXISTS `person`;
CREATE TABLE `person` (
`id` int(32) NOT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
my.cnf:
[mysqld]
log-bin = mysql-bin
server-id = 1
start.sh:
#!/bin/sh
echo "start MySQL"
service mysql start
sleep 5
echo "initialize database"
mysql -uroot -pKohc9hai < /mysql/init.sql
echo "initialization complete"
tail -f /dev/null
By getting deeper, I think that I determined that the problem is in the file start.sh (Maybe I'm wrong).
There are logs of this container:
start MySQL
mysql: unrecognized service
initialize database
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
initialization complete
Maybe someone can help me with the solution to this problem.
I'v just started to study Docker.
mysql: unrecognized service
From next, you could see there is no mysql service in container, so you surely failure:
$ docker run --rm mysql ls /etc/init.d
hwclock.sh
In fact, mysql image use next to start mysql service:
exec gosu mysql "$BASH_SOURCE" "$#"
So you need to follow the same way.
BUT, for your scenario, looks you just customize start.sh to init some sql, while it's in fact already supported in official image:
Initializing a fresh instance
When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions .sh, .sql and .sql.gz that are found in /docker-entrypoint-initdb.d. Files will be executed in alphabetical order. You can easily populate your mysql services by mounting a SQL dump into that directory and provide custom images with contributed data. SQL files will be imported by default to the database specified by the MYSQL_DATABASE variable.
So, what you need to do is next in Dockerfile (Maybe need to specify MYSQL_DATABASE also):
COPY init.sql /docker-entrypoint-initdb.d
The document is quite old (docker version 1.13.1! Now 19.03.13!!). No special setting is required to use MySQL image. All you need to do is:
docker run --name foo -d -p 6603:6603 mysql:latest
How make mariadb federated with ssh?
DROP SERVER IF EXISTS `any_server_name`;
CREATE SERVER ' any_server_name ' FOREIGN DATA WRAPPER 'mysql' OPTIONS
(HOST 'host.com',
DATABASE 'database_name',
USER 'user_name',
PASSWORD "password",
PORT 3306,
SOCKET '/var/lib/mysql/mysql.sock',
OWNER 'root');
DROP TABLE IF EXISTS federated_table_name;
CREATE TABLE federated_table_name (
column_1 INT(11) NOT NULL,
column_2 INT(11) NOT NULL,
column_3 VARCHAR(255),
...
column_n VARCHAR(256)
)
ENGINE="FEDERATED" DEFAULT CHARSET=utf8mb4
CONNECTION=' any_server_name /table_name';
MariaDB doesn't support SSH, so you can only tunnel a connection and connect to the port of tunneled connection.
If you meant TLS/SSL instead of SSH, the answer is also no. CONNECT and FEDERATED engines don't support secure connections yet. A solution to store the TLS/SSL parameter in the client.mariadb section of the configuration file will also not work, since the call which forces to read the configuration file is commented out in the source code.
If you need that feature, please file a task on MariaDB Issue tracker
A workaround for it would be to use table type ODBC and to pass the TLS/SSL parameters in the DSN.
When I try to create a new database(m) in xampp mysql command window then I'm getting an error message
"ERROR 1044 (42000): Access denied for user ''#'localhost' to database
'm'".
Then I created that database by using phpmyadmin but its not shown in mysql command window when I type show databases command there. Can anybody tell me how can I get rid of that error message and can successfully create new database by using mysql command window in xampp? (I'm using windows xp professional service pack-2)
-Thanks.
Are you logging as a root?
Browse to the mysql.exe containing foler and try typing this in the cmd:
mysql.exe -u root --password
Try to initiate your mysql client with a specific username and password ( if you have set one )
mysql.exe -uroot [-p]
Edit:
Add this to your my.cnf [client] section to log-in without any parameter
[client]
user=root
http://dev.mysql.com/doc/refman/5.5/en/mysql-command-options.html
RESOLVED:** Thanks to all for your kind replies. I solved that problem.
I changed the 'user' table in 'mysql' database by using phpmyadmin and set the fields to 'Y' while those were 'N' where host was 'localhost'(so localhost wasn't able to create or drop any database).Now its possible to create new database by 'xampp\mysql\bin\mysql.exe'.
AND **to get .frm(table definition), .MYD(table data) and .MYI(table indices) files for a table in mysql data folder,I SET type=MyISAM and collation=utf8_general_ci so it would be easy to copy the database to another pc or server.
I know you've solved the problem .I had the same problem ,but the answer is simple .Answer :if you type "localhost" in your browser ,after selecting the language , you can select "phpmyadmin" .then as you said you can click on the "Databases" tab ,then from the list of databases select "mysql" and eventually you can see that the last table of this database is "user" table.if you then click on the "browse" button right in front of the name of the table which is "user". now you can see the "user" table in detail.you can see under the "host" column there are 3 "localhost" cells ,but only one of them has value of "root" in the "user"
column which is the next .so if you want to connect mysql via command prompt , if you have not set password yet ,( c:\xampp\mysql\bin\mysql.exe -u root ) not
( c:\xampp\mysql\bin\mysql.exe ) or not ( c:\xampp\mysql\bin\mysql.exe -u root -p ) .
I am not getting a clue to:
simply login to postgreSQL
Create a database
Add a table
Insert a record
Delete , update etc
These things are normally very very easy using mysql . Can someone help me setup following alternative for postgresql
a) Reset default password -- Very Clean description ,
I do not find same level of clarity for PostgreSQL
(Any documentation link is highly appreciated)
b) We know the superuser for mysql is "root" what is the same for PostgreSQL
c) from command line how to ( PostgreSQL ones ?):
mysql -uroot -proot
create database testdb;
use testdb;
create table test(id int(11) auto_increment, name varchar(20), primary key(id));
insert into test(name) values("testing one"),("testing two"),("testing three"),("testing four");
select * from test;
update test set name=concat(name,now()) where id =3;
delete from test where id =4;
drop table if exists test;
drop database if exists testdb;
EDIT MAC OS
# Default password reset
sudo mate /Library/PostgreSQL/9.2/data/pg_hba.conf
replaced (md5 with trust)
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
with
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
save
executed the Reload Configuration.app
login to postgresql without password :
$ psql -U postgres
postgres# ALTER USER postgres WITH PASSWORD 'new password';
\q
-revert back all the changes in pg_hba.conf (replace trust with md5) and save
-reload configuration
Now I can login to postgresql with new password
psql -U postgres
Password for user postgres:[my new password]
To login:
psql -d postgres_dbname -U postgres
Create Database:
create database testuser;
\c testuser; /*use testuse as mysql*/
Create Table:
create table employee (Name char(20));
Insert :
insert into employee VALUES ('XAS');
Update Link
Delete Link
Reset Password : See Here &
See Here Too
Simply login to postgreSQL
psql -U postgres -W template1
-U = username
postgres is root
-W = ask for password
tempalte1 = default database
Create a database
-- Create the database from within postgresql
create database my_database_name
-- Connect to the database
\c my_database_name
-- Create the database without logging in
createdb -U postgres -W my_database_name
Add a table
Insert a record
Delete , update etc
All the above from 3 to 5 are like in MySQL
For resetting postgres forgotten password this link is a good reference.
postgresql is a completely different system than mysql; so do not assume things will be like mysql. They are completely different animals entirely; some of your SQL statements might not work, especially if you are using a MySQL proprietary command.
To login to postgresql, use the psql command shell
CREATE DATABASE
CREATE TABLE
INSERT
For all other basic SQL commands, consider going through the tutorial
User access control is something more fine grained and detailed in postgresql. There are users and roles. A user is simply a role that has the ability to login (like MySQL), but in postgresql you can have roles (an account) that cannot login.
What access a role has is defined in pg_hba.conf. This file defines if a role can login at all, by what means are they authenticated, from where they can login and what database they have access to.
ALTER USER is used to reset credentials.
The "root user" for postgresql is typically postgres; and this is a system user that is created during the install process. For Windows, the binary installer will ask if you want to launch the service as this user as well.
Please take a look at this PostgreSQL error 'Could not connect to server: No such file or directory'
Try to install postgresApp, this solved my problem which was the same of yours.