Update passwords of SQL Server 2008 R2 users via script - sql-server-2008

Background: we have an old system in production on SQL Server 2008 R2. Due to some reasons real time replication to secondary is not implemented. In case of disaster at primary, we will switch to secondary machine and restore latest available backups (except for master, msdb, model dbs). Each of our user accesses the application via SQL Server database users.
Issue: now my concern is since we will not restore master database to the secondary server, how to deal with situation where users at primary database change their passwords. When we activate the services from secondary, how to restore their passwords from primary?
One approach is that we export the users from primary and restore it on secondary. But issue with this approach is that the users creation date on secondary will be change and this will be a audit issue. Is their any way we can update passwords only?
Regards
Salman

dbatools has very handy PowerShell cmdlet (Copy-DbaLogin) to do this. Just create a job to run the following script:
Copy-DbaLogin -Source sqlserversrc -Destination sqlserverdst -Force
It will copy all logins from sqlserversrc to sqlserverdst and overwrite them in case they exists (which will handle password changes).
Another option is to use SSIS and Transfer Logins Task.
If you upgrade to SQL Server 2012 (or newer) you can also consider using contained databases. Then you will not need logins on the server, because the users with passwords are part of the database itself.

Related

I need connection to an Access Database from a mysql stored procedure to update tables i already create in mysql db

The access database is on server in folder. I need to create a stored procedure to connect to the access database and update the table data. It can be truncate then an insert. It is connecting via stored procedure to the access database i cannot figure out. It has to be done via a job on a schedule.
MySQL (the Sun- then Oracle- owned product) lacks the plumbing to connect to external tables unless they're on other MySQL servers. That is, it only has a FEDERATED storage engine. So, with MySQL you'll have to find some other way to handle your requirement; a MySQL event or other stored code cannot hit your Access tables.
MariaDB, the MySQL fork, has a CONNECT storage engine. It allows the server to hit external tables via ODBC, so you can hit Access with it. MariaDB is almost entirely compatible with MySQL, so maybe you can replace your MySQL server with it. The CONNECT documentation says this, however.
...these table types cannot be ranked as stable. Use them with care in production applications.
To me, that warning means don't do it!. Especially with a busy business-critical application (like a credit department might use) you don't want even a little bit of instability. If you truncate a table and then the reload fails, you'll be able to hear users yelling from the next county.
Your requirement is, I believe, to extract the contents of one (or more) Access tables and import them into a MySQL table. That kind of operation is called extract-transform-load etl. It seems you use SSIS for the purpose. That should work, because SSIS can connect to Access (of course) and to MySQL via the Connector/net or Connector/ODBC drivers.
But, scheduled SSIS packages get run from SQL Server database servers. You didn't say you have one of those at your disposal. If your org does have a production SQL Server instance, you can put your Access - to - MySQL package into it.
Otherwise you will have to figure out a way to run your scheduled etl job without relying on a database job (or event, as they're called in the MySQL world). For that you'll use the Task Scheduler on Windows, or a cronjob on a UNIX-derived OS like Linux or FreeBSD.
I bet you can do this work reliably from a Windows PowerShell script or a Linux shell script.

Link local SQL Express 2005 database to online MySQL database?

I have a software dumping values to a local SQL Express database once a day. What I really need is this data in an online MySQL database. The software cannot be reconfigured to save to a different database setup.
Is there any way of linking the two and having any updates to the local database sent to the MySQL database?
Thanks,
Joe
Do you have access to the server the software sits on? I would create a script and a scheduled task that is on the server, and pulls from one and pushes to the other. This would allow you to code and configure some sort of fail safe mechanism should one or the other be down. Otherwise one other option is to add a trigger for the SQL server for inserts/updates, and configure a MySQL DSN:
http://www.ideaexcursion.com/2009/02/25/howto-setup-sql-server-linked-server-to-mysql/

Back up MySQL using phpMyAdmin

I have used MySQL for my application written by PHP. After a time its data will be great and I need to make a backup from them. Also, I need I can restore the backup data whenever I need. My question is if phpMyAdmin can make backup and resotore it secure and completely without any data lose?
(I have both MyISAM and innoDB in my database structore)
Also, if you know any other IDE to make backup and restore it without showing the database structures and tables to the end-user, please tell me their names.
Thank you.
If you're running MySQL on your own server you may copy the database folder, but the MySQL server would have to be stopped first. Anyway I'd recommend dumping the databases through phpMyAdmin (export function) or via the command line (mysqldump). Using the latter, you may write a batch script that also compresses and encrypts the content of the dump file.
Using the built in Import and Export? The only data loss would be everything after the backup until the time the backup was imported.
Securely? That's an entirely different topic. There's too many things to consider to call anything secure but if you're using https or on a trusted LAN, then yes, I guess it's secure.
I think MySQL Workbench can do exports and imports.
If would you wish to backup MySQL database more securely and periodically without loss of data to remote server or local drive (local hard disk or mapped drive), then you can try Vembu StoreGrid http://www.vembu.com/, a leading backup software trusted by more than 2700 service providers world wide. Once you configured single backup by selecting entire database then automatically newly added database will be backedup on upon next backup time. Also, StoreGrid backups only the incremental bytes of changes on next incremental schedule.
Vembu has a solution for almost everyone, just check them below:
For Service Providers : StoreGrid Service Provider Edition
For Business/Offices : StoreGrid Professional Edition
For Home Users: Vembu Home
For Resellers who don't want to have their own storage : Vembu Pro
For Hosting Providers: StoreGrid Hosting Provider Edition (yet to be released)
For your requirement, we would suggest the Professional Edition http://storegrid.vembu.com/online-backup/network-backup.php of StoreGrid. Try it!!!
Regards,
Thileepan
vembu.com

transferring data from my database to my friends database

Just created a database in my own MySQL server. Now I want to transfer the data from my MySQL server to one of my friend's MySQL server.
Any idea how this can be done?
Also, how would I do this if I use oracle server?
If you have an access to his database - you can create dblink
Otherwise you have to export a dump and send it to your friend.
I have had to copy full databases (as well as just selected tables) between servers before and a SQL dump can be cumbersome if you have a lot of data. If you have access to both servers you might consider an application called "Navicat". It is a MySQL GUI interface to manage databases.
You can have multiple databases on separate servers open at the same time, and can even "drag and drop" tables between databases and databases between servers.

Remote backup of MySQL database

Our Java server application logs data to a SQL database, which may or may not be on the same machine. Currently we use MS SQL Server, and we're now porting to MySQL. A user configures database backup parameters on our app server, e.g. time of day to run a backup, and the app server executes SQL Server's BACKUP DATABASE command at the appropriate time, via a sproc. It does incremental backups daily and full backups weekly.
MySQL lacks an equivalent feature to tell the database from a client connection to back itself up. Options we're considering are:
Create a UDF to shell out to mysqldump (or copy database files), which can be called from our app server via a sproc. Essentially we'd be implementing a version of BACKUP DATABASE for MySQL.
Create a service to run on the MySQL box that can get the backup settings from the app server and run mysqldump (or file copy) locally.
Create a backup sproc to mimic mysqldump, e.g. SHOW CREATE TABLES and SELECT INTO OUTFILE for each table.
Setting up a cron job, Perl script, third-party app or other tricks that'd work great in a data center aren't preferred; this is a shrink-wrap package that needs to be pretty robust and hands off.
Database sizes can range from roughly 10MB to 10GB.
I'm aware of the binary logs for the incremental piece. I figure the general solution will probably apply to them as well, if we decide to use them.
This is all on Windows 2003 32-bit or 2008R2 64-bit, MySQL 5.1.
The UDF option seems the best to me. The UDF Repository (http://www.mysqludf.org/) has mysqludf_sys, which may be all we need, but I thought I'd ask for opinions since after extensive googling it doesn't seem like others have reached the same conclusion, or maybe our needs are just out of the ordinary. Our app is the only thing in MySQL, so I'm not worried about other users having access to our UDF.
Any solutions I'm overlooking? Any experience with using UDFs in such a way?
Thanks,
Eric
For this an other reasons we decided to collocate our application with the database, so this problem became moot.