Connecting To Local mySql Database - mysql

Currently I am connecting to an online mySql database. I would like to switch it to a mySql database on my local hard drive and am having problems with the syntax. Unlike the online one I have no UserID or Password. Any help is appreciated. Thank you.
(mysql_real_connect (conn,"urlock.db.5513143.hostedresource.com","urlock","passxxx","useridxxx",0,NULL,0) !=0);
tried this:
(mysql_real_connect(conn,"c:\urlock.db","urlock","","",0,NULL,0) !=0);
didn't work.

That second parameter needs to be a host which represents a network connection. It cannot be an absolute file reference like you might do with MS Access files. So, you need to install MySQL5.X on your system as a service. If you've done this, verify it by either looking for an open port of 3306 (default) via a 'netstat -an' command or simply look in your services for 'MySQL ....'.
If not, download it here:
http://dev.mysql.com/downloads/mysql/
Once you get this you will be able to import the this database locally and be able to access it very similar to the online version. i.e. (mysql_real_connect(conn,"localhost","urlock","someuser","somepass",0,NULL,0) !=0);
Importing/exporting can be tricky but to point you in the right direction look into the mysqldump command.

I believe the second parameter should be the host. If it is a local mySQL, the
host is localhost.
The default username is usually 'root'.
Try this:
(mysql_real_connect(conn,"localhost","urlock","","root",0,NULL,0) !=0);

Most (if not all) installations of MySQL should have default accounts. There should at least be a root account. http://dev.mysql.com/doc/refman/5.1/en/default-privileges.html

You'll need a CONNECTIONSTRING
SqlConnection con = new SqlConnection(connectionString);
con.Open();
If you add your database in visual studio under Dataconnections, you can see the connection string under properties
ADDED:
If its an sqllite db, you need to use an SQLCeConneciton
private static string connectionString = #"Data Source=path/to/the/database/db.sdf";
private static SqlCeConnection con = new SqlCeConnection(connectionString);

Related

jdbc sqlserver url string

I've found this in a software developed by another with j2ee spring_hibernate tomcat_v7 and jre7.
the dbURL is written as follow
dburl = "jdbc:sqlserver://remoteip\\local\\local:1433;database=dbname"
what does the double local means? when removed them the link to sql server 2008 doesn't work anymore.
simple answer to this is in the "integratedSecurity=false;"
when you want to connect to the database installed in the same machine and by the windows authentication then use "integratedSecurity=true" without login or password while you have to put the dll existant in the auth file in the jre lib directory
however if you want to use another machine (remote) this time the integratedSecurity will never work so you will have to choose the sql server connection and then absolutly use "integratedSecurity=false"
String connectionUrl = "jdbc:sqlserver://ServerName\\databaseInstance:1433;databaseName=DBSS;integratedSecurity=false;user=user;password=pass";
you may also open the sql server config manager and set TCP/IP to enabled, the ip adress (IPALL) dynamic to nothing (delete the 0) and the port to 1433 (same as the string connection) and restart the sql server service
you'll probably also need to create a firewall unbound rule for that port.
hope this will help others.

How can I access my database in xampp remotely?

I'm doing a Java project in Netbeans. I use xampp server in phpmyadmin for the database service. But each time I run the project, I have to start the xampp server. And also it is only available in my laptop. How can I configure it such that it wherever(any other computer) I run the Java application, the database gets automatically connected and data is retrieved. In the Java code, the connection is made like this:
Connection con = null;
try {
con = DriverManager.getConnection("jdbc:mysql://localhost/food_waste","root","");
JOptionPane.showMessageDialog(null,"Connected");
return con;
} catch (SQLException ex) {
Logger.getLogger(Make_donation.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(null,"Not Connected");
return null;
}
Do I have to change anything over here as well. I'm looking for solution for a really long time. Any kind of help will be greatly appreciated. Thanks.
You will need a server where you can install database. The server can be something that you rent or some computer that you have at home that you use as a server.
You need to make sure that the database is reachable from outside (for MariaDB: https://mariadb.com/kb/en/configuring-mariadb-for-remote-client-access/).
In your connection string you need to replace "localhost" with something that is identifying your server.
If you are renting a server you can use the static IP. If you are using a computer at home as a server you will most likely have a dynamic IP. So if you want to connect from outside your home network to your database you will need something that handles the change of IPs (something like noip.com or any other dynamic DNS service). So you would need to replace "localhost" with an URL that is provided by the service you choose. And you will need to use port-forwarding if you are behind a router.

What is the connection string for Google Cloud mySQL, in node.js?

The scenario is as follows:
I am writing an node.js app locally and want it (the mySQL modul, rather) to connect to a mySQL db running on Google Cloud Platform.
I can not get the connection string right and keep getting errors. GCP holds two names for the database - one i picked, one generated, more complex. Problably I should supply one of these into the connection string as "database", the host is likely the IP address with port (or not(?)), I am not sure what the "user" should be, or if it is necessary. Not enough info on the GCP help pages or elsewhere.
tl;dr: I need the following to connect a node.js app with a mySQL module remotely to a GCP database:
var con = mysql.createConnection({
host:"11.222.333.444:3306",
user: "me"
password:"passwo3d",
database:"projectname-1528892969949:europe-west5:dbname"
});
Thank you!
The raw connection string should look something like: mysql://user:password#localhost:port/db
So I think your code should look something like:
var con = mysql.createConnection({
host:"11.222.333.444", <-- remove the port from your string
user: "me"
password:"passwo3d",
database:"dbname" <-- you have it as the instance name .. its just suppose to be the DB name
});
You can also try connecting to the instance using the cloud proxy setup. You host would just be localhost.
Finally you can always go the GCP console -> go to your instance and open up a shell. I think they print out the gcloud cmd in there and you can copy values from the console as well.
Depending on how you are pushing your code, you may have to change a few connections strings in your manifests as well. If you can share those I can help further.
For that to happen, you have to first enable remote access for your mysql on your GCP. A step by step guide is over here, you can leave the first few steps for installing mysql.

PowerBuilder MySQL Connection

How do I connect my PowerBuilder to MySQL?
First I would like to use Database Painter to conenct to my local MySQL Database so I can create my datawindows.
Then I would like to make a DSNLESS connection so I can just add .ini and ProfileString my connection.
To create a DSN-less connection, I pulled this syntax from http://www.connectionstrings.com/
ODBC:
SQLCA.DBMS = "ODBC"
SQLCA.DBParm = "Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername;Password=myPassword;Option=3;"
Note that you might have to tweak the version number (5.1) to match the version you download.
// Profile Transporter3
SQLCA.DBMS = "JDBC"
SQLCA.LogPass = "tss"
SQLCA.LogId = "root"
SQLCA.AutoCommit = False
SQLCA.DBParm = "Driver='com.mysql.jdbc.Driver',URL='jdbc:mysql://localhost:3306/mydb'"
the only thing is you need to set classpath of the jar file for which i posted in Linked in please refer
now it connect to MySQL the big problem arises is Ignore space after Function name
I dont understand how to set option for this in JDBC for odbc there is option. i go through documentation
of connector J but no such option. This problem arises only for PowerBuilder so i request you if you know the solution please provide it.
i resolve this issue mysql option -i or --ignore-spaces is going to work so i set that option in configuration files i.e. my.ini
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,IGNORE_SPACE"
stop MySQL service and then started it works smoothly
You have to configurare db profile like servername, database, etc., . In this preview tabpage check the connection and copy &paster the commands in application open event.
By PB team

Cannot connect Delphi App to mySQL database

I have installed a local server Xampp, which is running mySQL database in Windows. I created a Database on it with one table. The thing is I cannot get a connection to the database when I use the dbExpress TSQLConnection component. When I set the properties as follows:
ConnectionName = MYSQLConnection
Driver = MySQL
Database = databaseName
HostName = localhost
password =
UserName = root
When I change the connected property to true, I get the following error:
Borland.Data.TDBXError: DBX Error: Driver could not be properly initialized. Client library may be missing, not installed properly, of the wrong version, or the driver may be missing from the system path
I have tried making a connection to the database using the Data Explorer, but I still get the above error. I do not know what I'm missing or doing wrong.
Im using Delphi-XE2.
with mySQL on the server: MySQL client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $.
I have also tried using an ADO connection, but I do not know how to set the connection string.
I'm still a noob and just want to learn how to make a connection to a mySQL database running on a web server. I cannot afford to buy any components.
Try this!
Did some google Fu - and stumpled upon this link : http://wiltonsoftware.com/posts/view/getting-embarcadero-dbexpress-mysql-working-dbx-error-driver-not-initialized
That seems to fit your needs.
My previous answer was no help .. hope the new one is better.
Old answer:
Make sure you have Data.DBXMySQL in your uses clause.
OK. I'll try a different approach.
Is it working if you setup the connection in the DataExplorer?
If not - then it's not a problem with the uses clause.
(and you obviously have tried that - sry . must be tired :-))
Otherwise a unit could be like this.
unit Unit1;
interface
uses // <-- Uses normally goes right after interface .... (you probably already have one)
Data.DBXMySql;
implementation
end.