Liquibase can't connect to the SQL Server [duplicate] - mysql

This question already has answers here:
Connect Java to a MySQL database
(14 answers)
Closed 5 years ago.
I am fairly new to liquibase and try to set it up on my own computer, running Windows 7 with a local MySQL Server. I have installed the JDBC driver (4.2), opened the TCP/IP Port 3306 on my Firewall and the Server, installed liquibase and added it as a PATH in the environment variables.
As a first command i tried using this:
C:\Users\Marius>H:\Liquibase\Liquibase \
--driver=com.microsoft.sqlserver.jdbc.SQLServerDriver \
--classpath="C:\\Program Files\\Microsoft JDBC Driver 6.2 for SQL Server\\sqljdbc_6.2\\enu\\mssql-jdbc-6.2.2.jre7.jar" \
--url="jdbc:sqlserver://localhost:3306; databaseName=Test" \
--changeLogFile="H:\Liquibase\dbchangelog.xml" \
--username=liquibase \
--password=liquibase \
Update
But when executing I only get:
Unexpected error running Liquibase:
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection
to the host localhost, port 3306 has failed. Error: "Connection
refused: connect. Verify the connection properties. Make sure that an
instance of SQL Server is running on the host and accepting TCP/IP
connections at the port. Make sure that TCP connections to the port
are not blocked by a firewall.".
The Server is definitely running since I am able to connect to it with telnet, mySQLWorkbench and several other tools.
When running the command with --url="jdbc:sqlserver:localhost:3306; databaseName=Test", I get a different error code.
Unexpected error running Liquibase:
liquibase.exception.DatabaseException: Connection could not be created
to jdbc:sqlserver:localhost:3306; databaseName=Test with driver
com.microsoft.sqlserver.jdbc.SQLServerDriver. Possibly the wrong
driver for the given database URL
I tried this again on another computer with a SQL Server 2017, a different JDBC driver (6.0 and 6.2) and Windows 10 as the OS.
Deactivating the Firewall doesn't do anything, neither does a clean install of everything.
Any help is appreciated.

MySQL is a different product to Microsoft SQL Server. Given you have said you can connect using MySQL workbench, this is probably the product you have installed.
Instead of trying to connect to the non-existent Microsoft SQL Server, try using a MySQL driver instead.

Related

Problem with mysql workbench and xampp server

I am trying to create a project with mysql. For the past two days I had been using XAMPP server for the mysql server and mysql workbench to use it and it has been working perfectly. Today after having to restart my pc for a windows update, when I turned on the XAMPP mysql server and tried going to my connection in mysql workbench, mysql workbench is giving me an error
Could not connect; Server may not be running Message: Lost connection to mysql server at 'waiting for initial communication packet'. system error 10060
I have tried multiple solutions; Changing the port of the mysql server. Using a different username and password, the root username. And have tried restarting my computer multiple times to fix the problem. If any more information is needed to find the problem I will update this question to provide more information.
UPDATE 1:
I left my laptop running and when I returned the workbench had connected successfully. I believe the problem comes from restarting the pc as the day after I posted this question I restarted my pc to fix a problem and I am currently having the same situation.
Maybe the problem is the Windows Firewall or the Antivirus.
If the server is running all the time and the service not stop, the port is blocked.
Check if the default port is Listening:
C:\Windows\System32>netstat -an |find "3306"
Or you can use the Microsoft Tool PortQry.exe download from:
https://www.microsoft.com/en-us/download/details.aspx?id=17148
Example of use:
C:\PortQryV2>PortQry.exe -n 127.0.0.1 -e 3306
Querying target system called:
127.0.0.1
Attempting to resolve IP address to a name...
IP address resolved to WF-SA02
querying...
TCP port 3306 (unknown service): LISTENING
C:\PortQryV2>
Might be an SSL problem. The problem is: XAMPP does not use SSL and MySQL Workbench uses SSL as a default setting.
You can select "If available" in the Use SSL dropdown box of the SSL tab of the connection pane. Use the tool icon in the startup window to edit already existing connections. Works in MySQL Workbench 8.0.28+

Connect to SQL server with custom port while executing installer

I have InstallShield 2013 basic MSI project. During installer execution I need to connect to MySQL Server which is running on 3310 port. Default port is 3306 and installation runs successfully, but when I try to connect to server with different port - installer cannot connect to MySQL server.
I tried to set custom port like described here
ServerName,3310
But it didn't work for me. I also tried to connect by IP of server and port delimited with ":" but it also had no effect.
When I try to connect to server by typing hostname I get this error: "Can't connect to MySQL server on 'hostname'"
When I try to connect to MySQL server by typing hostname,port I get the following error: "Unknown MySQL server host 'hostname,port'"
Can anyone tell me what I am doing wrong or what I need to do to connect to MySQL server with custom port?

secure auth error connecting to SQL server from RMySQL

I m trying to connect to a MySQL server on a VM from RMySQL, here are the commands i executed
c<-dbConnect(MySQL(), user="root", password="passw0rd", dbname="leopard", host="one-1368")
It is showing the following error
RS-DBI driver: (Failed to connect to database: Error: Connection using old
(pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)
I m using MySQL client 5.6 on my system and the VM shows that it is running 5.5. I think it might be an issue on the server version.
Any help would be appreciated. Thank You
You may have an old my.cnf configuration on your local machine. You can override the client option secure_auth in my.cnf or in a specific config file you pass to dbConnect()
dbConnect(MySQL(), default.file="your-file.cnf"
The info on the setting is here:
https://dev.mysql.com/doc/refman/5.6/en/mysql-command-options.html#option_mysql_secure-auth
As an aside, you should really not be using 4.1-style password hashing :)

mySQL command line works but ODBC and workbench do not

I am trying to test a connection to a mySQL database running on a remote linux server. I am running Windows 7 and have mySQL installed on my machine as well as the 32-bit ODBC driver. I can connect from the DOS command prompt with no problems. But I cannot connect using mySQL workbench or with ODBC (from MS Access).
In MySQL workbench my error is:
Your connection attempt failed for user 'username' from your host to server at 'x.x.x.x:x': Unknown MySQL server host 'x.x.x.x' (0)
In MS Acess (ODBC driver) my error is:
Connection faile:[HY000][MySQL][ODBC 5.2(w) Driver]Can't connect to MySQL server on 'x.x.x.x' (10061)
I've searched stackoverflow extensively and I found lots of people who can't get ANY connection to work. But I know I can log in from my computer. Could it be something other than ports?
Please make sure you are using correct ip address in MySQL workbench to connect to your mysql database

play framework - connect to linux mysql

I am new play framework. I am trying to connect to mysql database on linux server. it is not working !!
I am getting an error:
A database error occured : Cannot connected to the database, Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
anyway I am able to connect linux server through my MySQL Work bench.
application.mode=dev
%prod.application.mode=prod
jpa.ddl=update
db.url=jdbc:mysql://<ipaddress>:3306/<database>?useUnicode=false&characterEncoding=ISO-8859-1&connectionCollation=utf8_swedish_ci
db.driver=com.mysql.jdbc.Driver
db.user=<user>
db.pass=<password>
ensure that you have the correct ip address and port nunmber for mysql in the config file (as well as the correct username/pwd).
you can check if mysql is listening on the port (try netstat -an | grep 3306).