I am a totally new on Amazon EC2 and I have just created an AMI instance (Linux).
I've installed php, apache and mysql in that instance as well and I have a question about it.
There is a .pem file which is used as a password when i connect to the instance.
If i want to connect to the instance through Visual studio, How can i get the password?
I mean, In an API function, to connect to database requires the password of the server. However, EC2 instance has .pem file as a password so how could i retrieve .pem file as a real password? (I want to make a program in VS and i need to connect to MySQL which is in the EC2 instance) well, basically, Is it possible to retrieve the password #.#????
Thanks in advance indeed!
Visual Studio Integration
One way to do it is to download the Connector/Net driver for MySQL and install it. Then in your Web.config file add a connection string similar to the below to connect to the database. Then setup your models to reflect the tables in your MySQL database. Create a DbContext class with the same name as the connection string name in your Web.config file. Then you can work with it as normal.
<connectionStrings>
<add name="SuperSmartDB" connectionString="server=ec2-50-34-34-157.compute-1.amazonaws.com;user=root;database=superrdb;port=3306;password=nunya123;" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
If new to Visual Studio
Once all your models are created you can create a new controller. When creating the controller: set model class to the table you want to work with and the data context class to the context that matches your connection sting in Web.config. Select to have the CRUD create via Template. Doing so will create the basic Create, Read, Update, and Delete controller actions and views for you.
You don't need .pem file to connect to database through VS. .pem file is needed when you try to SSH into the instance. For connecting to MySQl DB, MySQL host,user and password are required.
Related
I am trying to install dotnetnuke in my localhost but not able to installing dnn and below connection string used in webconfig file.
<add name="SiteSqlServer" connectionString="Server=(local);Database=d1;uid=;pwd=;" providerName="System.Data.SqlClient" />
Below error getting:
I am installing dnn in local host, please help to out this headache installation.
Integrated will attempted to use Windows Authentication for the database connection.
You either need to create a SQL authentication account and choose the "User Defined" option, or you need to add the user for your app pool to SQL to give it access to the D1 database.
I prefer to just use SQL Auth accounts, always ends up easier in my opinion.
I like to setup a dedicated MySQL server in a LAN accessible from other computers of this network. How can I setup the database server and the clients?
How can a Grails application can access the MySQL from the same LAN?
If your MySQL server is going to run on Windows then you can configure it with the installation program. For example, I downloaded the install file mysql-installer-community-5.6.20.0.msi (versions change quickly) and it offers the option of installing just the server:
Just follow the screen prompts and take all the default values (strongly recommended). The main values to remember are:
The default network port number 3306.
The server's ip address.
The username(s) and password(s) that you created that have access to
MySQL.
Then I suggest you download HeidiSQL and configure a connection to your new MySQL server, that way you can manage your database server remotely:
Hope that helps.
You are asking 2 differents questions.
To set up mysql connection in your grails app, did you at least try to read the doc ?
http://grails.org/doc/latest/guide/single.html#dataSource
It's just a jdbc connection string :
https://www.google.fr/?gws_rd=ssl#q=jdbc+mysql+connection+string+example
It's more than just the JDBC connect string. You won't get far without a driver, so uncomment the sample entry in BuildConfig.groovy in the dependencies section and update the version to the most recent:
dependencies {
...
runtime 'mysql:mysql-connector-java:5.1.34'
}
Set the driverClassName in DataSource.groovy, along with the correct JDBC url for your database. Replace <server> with the server name or IP address, and <dbname> with the correct database name. You will likely also want to add parameters at the end of the url in the querystring. And if the port is non-standard (3306 is the default) then add that in also. To ensure that you use INNODB tables (older versions of MySQL default to MyISAM), specify the MySQL5InnoDBDialect (or a subclass):
dataSource {
...
driverClassName = 'com.mysql.jdbc.Driver'
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
url = 'jdbc:mysql://<server>/<dbname>'
}
Run grails compile to download the driver jar and setup the classpath.
I created my scaled application on Openshift server with following command:
rhc app create MyApp jbossews-2.0 -s
Then add Mysql:
rhc cartridge add mysql-5.5 -a MyApp
My application using Struts2, Spring & Hibernate. I configured the datasource as follow:
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/MysqlDS"/>
</bean>
The JNDI "MysqlDS" is defined in .openshift\config\context.xml with the connection url:
url="jdbc:mysql://5344d4de4382ec43c9000090-myapp.rhcloud.com:37941/mydb"
The problem is my scale app can not establish the connection to Mysql with an error:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect
3 times. Giving up.)
I'm sure the username & password to access the database is correct. It seem MySQL on Openshift server doesn't open its port. When I tried to use an external database on freemysqlhosting.net (with open host & port) the application run well. But I just want to use MySQL db on Openshift. Anyone who have experience on this please give me some suggestion. Thanks
Make sure that you restarted your application after adding the mysql cartridge, sometimes the environment variables don't show up correctly until you restart. Also try to ssh to your gear and see if you can use the "mysql" command to connect to your mysql database directly.
If you left the .openshift/config/context.xml unchanged, the JNDI name fore the MySQL datasource is actually jdbc/MySQLDS and not jdbc/MysqlDS.
This was changed some time ago.
The documentation here http://openshift.github.io/documentation/oo_cartridge_guide.html#tomcat-cartridge-integrations is unfortunately not correct.
I am currently facing a issue of how to migrate the database for user information which is created by default in VS 2012. When I create a project, a LocalDb\v11.0 is created with all user tables and database.
In my application I want to use MySQL as database. I am able to run, connect and access MySQL database running on MySQL workbench. But I am facing this issue of how to migrate User Access Controls i.e, Account Controllers and Home Controller are already given; Currently when I press on Login I am redirected to a page to enter my login credentials. Which uses this default SQL Express LocalDb.
I want to use the code functionality which is provided to me by Microsoft but want to use a MySQL database.
I am currently thinking of migrating from default SQL db in which Account/user tables are, to MySQL and then operate code with MySQL database. There is no specific post which targets this issue. I am really clueless now, can someone give some pointers as of where to start?
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-ImageRepository-20140121114624;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-ImageRepository-20140121114624.mdf" providerName="System.Data.SqlClient" />
I am thinking of making this Default Connection to point to mySQL Db that I have but this is not working.
you will need to modify your connection string to connect to your mysql database.
you will find more info here
mySQL DataSource on Visual Studio 2012
if you are using entity framework in your project it will be compatible with mysql.
I've developed an application using JSP, Spring Security, MySql. I deployed it on Cloudfoundry. But just war file and I binded mysql service. But I also have to configure MySQL database that consists of two tables, new user and it all in my own database. While i tested my application on localhost i prepared the database running manual scripts in MySQL command window.
Question: How can I make the same configurations in CloudFoundry? can I the same way run all commands and scripts manually or export the database somehow? if yes, how to do this. And what to write here now instead of localhost?
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/security_filter" />
thank you
Caldecott (vmc tunnel) is the correct way to access your cloudoundry database (for me it works and i am using ruby 1.8): http://docs.cloudfoundry.com/tools/vmc/caldecott.html
If that does not work for you you will have to do something manually (much harder):
Create a sample jsp/servlet application that connects to a mysql database (retrieving connection string, username and password as input from user). Then it will just run the sql statement against the database ( sql statement will be also input from user)
Bundle this application in your war
Now you have to retrieve database connection string/username and password. You can retrieve them from the enviromental variable VCAP_SERVICES. Just log log it in a startup listener (eg ServletContextListener)
Deploy your war and get logs from server (vmc logs ApplicationName). Get connection string, username and password
Logon to your application and use your database application to access the database using the db info you collected in the previous step
Just note that this is very dangerous approach. Just be sure to secure this database application or after the initial import remove it from your war and redeploy the application
As a final note you can check if such a database console application already exists so that you dont have to create your own (for example grails has a nice application for this http://grails.org/plugin/dbconsole. Maybe something exists for jsp/servlets)
Hope it helps if you have no luck with the ruby problem
You would need to create a mysqldump of your database.
Once you have the mysqldump file, you then use caldecott and perform vmc tunnel to your MySQL service. After you have establish a connection with your MySQL service on Cloud Foundry, you then need to use the mysql command to manually import the mysqldump file into your service.
For how to use vmc tunnel, visit the documentation site at: http://docs.cloudfoundry.com/tools/vmc/caldecott.html