TeamCity won't create its schema in SQL Server - sql-server-2008

I've installed a new TeamCity instance and just moved from internal storage to database (SQL Server). Followed the instructions at http://confluence.jetbrains.com/display/TCD7/Setting+up+an+External+Database and I know I've done the database part correctly as it wouldn't initially connect and I had to go back and turn on TCP/IP connections for SQL Server.
From the documentation I assumed that team city would create and maintain it's own database schema, but even though it's user is dbo the database remains blank - no tables, views or any other objects have been created.
When I try to connect to it in a browser I get "Database is empty or doesn't exist", and viewing the logs shows me "Schema contains no tables". I've obviously restarted the service and connected again each time.
Is there an install script I am missing? How do I get TeamCity to install it's schema?

When you are doing it like this, you will need to migrate the initial structure over to sql server. See here

Related

Synchronize a file from MySQL database to MS SQL Server

Is there a way to transfer a file from a MySQL database to a MSSQL Server using Nodejs?
Say, I have two applications,
Application A uses MySQL database and nodejs for the backend.
Application B uses MSSQL Server database.
I uploaded an image/document from Application A. I want to transfer/synchronize that image/document to Application B from the source code of Application A.
I've tried using mssql client for Node.js. It works as the rows from MySQL database is transferred to MSSQL Server database.
The problem is when I download the image/document from Application B, the image/document is a plain text with a file size of 0 byte.
Any suggestions or solutions that can help?
Thank you.
Requirements
Before starting the database migration, you will need the following software on your Windows machine :
A running MS SQL Server instance.
A running MySQL Server instance (this depends on your environment, we work with the MySQL server available in Xampp ). The idea is basically to have a MySQL server instance accessible on port 3306.
SQL Server Management Studio installed.
MySQL Workbench . This tool will allow you to migrate the data at the end.
1. Identify the database you are trying to migrate.
As a first step, you must verify that the database you want to migrate is exposed in your SQL Server instance. The easiest way to do this is through the SSMS tool. SQL Server Management Studio (SSMS) is an integrated environment for managing any SQL infrastructure, from SQL Server to Azure SQL Database. SSMS provides tools to configure, monitor and manage SQL Server instances and databases. Use SSMS to deploy, monitor and update the data layer components used by your applications, as well as create queries and scripts.
Open SSMS and access the database engine with the default Windows authentication (or from the connection you want to access) :
Connect to the server and browse the databases in the object browser. In our case, we want to export the my_database database, which, as you can see, is available in the Databases directory :
Now that you know that the database is accessible on the server, we will start with the migration using MySQL Workbench.
2. Start with the migration in MySQL Workbench
MySQL Workbench is a unified visual tool for database architects, developers and administrators. MySQL Workbench provides data modeling, SQL development and comprehensive administration tools for server configuration, user management, backup and much more. MySQL Workbench is available on Windows, Linux and Mac OS X.
Start MySQL Workbench and access the migration wizard from the toolbar (in this tutorial, we use MySQL Workbench 8.0) :
After opening the wizard, click on start migration :
This will open the source selection form. Here you will need to select SQL Server as the source relational database management system (RDBMS). A relational database management system (RDBMS) is a collection of programs and capabilities that allow IT teams and others to create, update, manage and otherwise interact with a relational database, most of which use Structured Query Language (SQL) to access the database. In our case, as mentioned in the article, we will migrate from a Microsoft SQL Server database to a MySQL database, so it will be the source. In our example, we have the MS SQL Server configured on the same computer and it automatically authenticates with Windows Authentication, if your server is hosted remotely, you will need to change the parameters according to your needs. You can test the connection :
And if you are successful, you can continue with the next step of configuring the target RDBMS, which means MySQL. As we mentioned at the beginning of the article, we assume that you already have a MySQL server configured and running in the background, in our case we used Xampp's MySQL server, which allows you to start/stop it with a control panel. The idea is basically to know the credentials to access the running MySQL instance, which in Xampp is accessible with a rootuser and an empty password :
If you are connecting to another MySQL server, you can configure it with SSH keys, etc. Now that both connections are established, you can proceed to the next step which fetches a list of schemas from the source RDBMS. This will create a list that can be toggled with all databases in the SQL Server instance, where you must select the database you want to migrate (as well as the schema name mapping method) :
In our case, we only want to work with the my_database database, so we will extract only that database. Now, if you continue and everything works as expected, you will now see the Source Objects window, which basically allows you to filter which tables you want to migrate or not, normally we would like to migrate them all :
Click next and you will see the migration page, which allows you to pre-check the MySQL script for each table and if there are warnings or errors that you need to correct manually, they will be highlighted in the list. For example, in our case, we have a warning (when importing it will be an error) that specifies a problem with the migration, if we read the code we will see a syntax error of incompatibility with the VISIBLEkeyword. In our example, simply removing that keyword from the lines will allow us to import the scripts without any problem :
After manually correcting the warnings and applying the changes, you can finally export the database structure to a file (.sql) or create the database in the target RDBMS (MySQL Server). In our case, it is easier to import it directly to the server, so we will choose Create schema in target RDBMS (you can export it to a file if you wish) :
Before MySQL workbench starts with the migration, it will check again for errors and warnings; if there are still any, you must manually correct them again :
Click on Recreate object, this will take you to the previous step to build the schematic once again, click next and if everything is successful you will see, everything should be marked as correct :
Finally, all that is left is the data. We already migrated the database structure, so now we need to transfer all the data:
Since we are working with both servers on the same computer, we can make an online copy of the data from the SQL Server database to the MySQL database. Click next and the data migration will start :
Once finished, you will now have the original SQL database in MySQL format on the server. You can now access your MySQL server, where you will find the database available.
Introduction
To integrate any database with nodejs, you need a driver package or you can call it npm module which will provide you with a basic API to connect to the database and perform interactions. The same goes for mssql database, here we will integrate mssql with nodejs and perform some basic queries on SQL tables.
Remarks
We have assumed that we will have a local instance of the mssql database server running on the local machine. You can refer this document to do the same.
Also make sure that the appropriate user created with added privileges as well.
Connecting to SQL via. mssql npm module
We will start by creating a simple node application with a basic structure and then connecting to the local SQL server database and performing some queries on that database.
Step 1: Create a directory / folder with the name of the project you are trying to create. Initialize a node application with the npm init command which will create a package.json in the current directory.
mkdir mySqlApp
//folder created
cd mwSqlApp
//change to newly created directory
npm init
//answer all the question ..
npm install
//This will complete quickly since we have not added any packages to our app.
Step 2: Now we will create an App.js file in this directory and install some packages that we will need to connect to sql db.
sudo gedit App.js
//This will create App.js file , you can use your fav. text editor :)
npm install --save mssql
//This will install the mssql package to you app
Step 3: Now we will add a basic configuration variable to our application that will be used by the mssql module to establish a connection.
console.log("Hello world, This is an app to connect to sql server.");
var config = {
"user": "myusername", //default is sa
"password": "yourStrong(!)Password",
"server": "localhost", // for local machine
"database": "staging", // name of database
"options": {
"encrypt": true
}
}
sql.connect(config, err => {
if(err){
throw err ;
}
console.log("Connection Successful !");
new sql.Request().query('select 1 as number', (err, result) => {
//handle err
console.dir(result)
// This example uses callbacks strategy for getting results.
})
});
sql.on('error', err => {
// ... error handler
console.log("Sql database connection error " ,err);
})
Step 4: This is the easiest step, where we start the application and the application will connect to the SQL server and print some simple results.
node App.js
// Output :
// Hello world, This is an app to connect to sql server.
// Connection Successful !
// 1

How to recover deleted mysql database

I have a mysql workbench on my server and today I checked just my all schemas are deleted resulting in halt of other application.I am confused how it has happened.Is there a way to check who has last connected to my workbench as few ppl have its access and how can I recover the lost database or there could be another reason for lost of all databases
MySQL Workbench is a client tool. If you installed it on a database server, then perhaps you should be checking who was logged on to the db server and that will be appropriately logged by the O/S. You might also want to review your security policy because it sounds like you might be sharing passwords and review which user accounts have DROP privilege on the databases.
Your databases might not show in Workbench if the connection is not properly configured (but the applications not working would suggest otherwise).

databases not visible in mysql workbench sidebar

It started with installation of wampserver for php, before that I had already running MySQL server 5.7 with all databases properly showing in the side schema panel. When I launched MySQL server after installation of wampserver 5.7.14, the password for root was overridden and no database except sys is showing. Also I found another user (mysql.sys) has been created (found in Users and Privileges). Then I looked for databases in path "ProgramData\MySQL\MySQL Server 5.7\Data", all databases are present in the folder (thank god they are not deleted). Problem is now for my website I get this error:
"Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration"
Exception Details: System.Data.Entity.Migrations.Infrastructure.AutomaticMigrationsDisabledException: Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.
I know this is not related to migrations because my database already exists but I don't know how to solve the problem that MySQL can see the databases in its "ProgramData\MySQL\MySQL Server 5.7\Data" again.
When you installed WAMPServer on a system that already had a MYSQL Server instance installed on it, you created a second MySQL Server instance. See your service you will have one called wampmysqld or wampmysqld64 and another called MYSQL.
Now, whichever service you start first will be the MySQL Server that Workbench, or anything else is talking to. And you will only see the databases that this MySQL Server instance knows about.
Correct Solution:
Stop WAMPServer
Start the MYSQL installed with Workbench
Backup all YOUR databases, NOT the ones created by MySQL like mysql, sys, information_schema, performance_schema
Stop this MYSQL Server.
Uninstall this MySQL Server
Start WAMPServer
Restore your databases to this MySQL Server instance
All should start working as expected now.
Connect your Workbench to WAMPServers MySQL Server
Update
Did a robust workaround, though not very suggestible but database is now accessible in MySQL workbench. Though I'm having the same error when opening the website on local web server. One thing that I did not mention before that environment is Windows based. what I did is copied database from the ProgramData MySQL path to "..\wamp64\bin\mysql\mysql5.7.14\data" path and refreshed schema in workbench. Any advice why I'm still having problem in web server.

Why aren't changes in MySQL database being updated in WebMatrix Database viewer?

I have MySQL running on my local machine. I have created several tables in MySQL workbench and connected WebMatrix to the MySQL DB. All the tables are present, however one of them does not contain any data (but it contains data in MySQL database). I have refreshed in Web Matrix, redone the connection string etc but the data does not display. When I try to run the SQL that populated the database in MySQL, inside of WebMatrix I receive this error from the Database Manager:
Object reference not set to an instance of an object.
My SQL is too long to post here. Any suggestions?
Restarted MySQL service and refreshed in WebMatrix. Data is now present. Not sure what was causing the issues but is resolved.

multiple machine MySQL through Workbench

I have recently started using MySQL Workbench, hence I apologise if this is not the proper platform to ask this question. I tried to figure out the solution of my own, but could not find any appropriate one.
Here is my situation: At my workplace, we have a huge set of data about the operational and financial figures such as sales, employee, profit, etc for European companies spread over past 7-8 years and new data keeps coming regularly. However, the problem is we work from different remote locations, me in one city and the other two colleagues in a different city. Normally, we share our work files (.xls/.doc) etc through Dropbox. So, we thought of creating a database in MySQL wherein we all can submit/edit/add this data so that we can filter and analyse this data on several ways once the collection is complete. And we plan to use and access it thereafter. We believe that this is ease a lot of our work. So all I want to know is: can all three of us collaborate simultaeousy (in order to add or edit the data) through workbench Server administration, like the way we collaborate our work through Dropbox? I want to be the host (like the administrator) and then want to allow the access to my colleagues.
Thank you for your time and answer. You may also refer me to any site or link to read more about it.
I think you are a bit confused about what MySQL Workbench is.
MySQL workbench is just a data viewer and administration tool that connects to a MySQL server, there's no data "stored" in MySQL workbench, all the data is stored in the server.
MySQL workbench can:
Connect to a MySQL server
Send SQL instructions and show the results: You can create and drop databases, send SQL queries, create and execute stored procedures and functions... all assuming you have the right privileges.
Perform administration tasks: You can create and drop users, grant or revoke permissions, etcétera
But the fact is: all is stored in a MySQL server... so the answer to your question is: Yes, you can work simmultaneously with your colleagues, if and only if all of you can connect to the same database server (as Mike W commented).
Addressing your comments, and clarifying more details:
MySQL is a database server. When you install it in a computer, all data is stored in that computer (aside from replication and other fine details). You should make regular backups of your data (MySQL has tools for that, one is mysqldump). If you want to access the data stored in your database server, you can do it:
By ussing the command-line client,
By using MySQL workbench or another GUI client program, or
By any program that can connect to the database server (via ODBC or specific libraries).
Focusing on MySQL Workbench, and addressing your specific question: If your machine breaks down, you can install the MySQL Server in any other machine, and load the backup into it. You will have to configure that new machine so that any of your coworkers can connect to it (that may imply that a new set of connection parameters is created).