Change SQL name
Jun 21
view sql name
select @@servername
Change name
sp_dropserver ‘old_name’
go
sp_addserver ‘new_name’,'local’
go
then restart sql
found info here:
http://coderjournal.com/2008/02/how-to-change-instance-name-of-sql-server/
Things that I work on
Jun 21
view sql name
select @@servername
Change name
sp_dropserver ‘old_name’
go
sp_addserver ‘new_name’,'local’
go
then restart sql
found info here:
http://coderjournal.com/2008/02/how-to-change-instance-name-of-sql-server/
Apr 15
reseting a mysql password on windows
1. stop mysql
2. Open a command prompt by selecting Start> run> typing in cmd
3. Changed directory to C:\program files\mysql\MySQL Server 5.1_orig\bin by running
cd “C:\program files\mysql\MySQL Server 5.1_orig\bin”
4. Started mysql from the command line with:
mysqld –defaults-file=”C:\Program Files\MySQL\MySQL Server 5.1\my.ini” –skip-grant-tables
5. Opened a 2nd command prompt
6. Changed directory to C:\program files\mysql\MySQL Server 5.1_orig\bin
7. log into mysql by typing
mysql
8. select the database
USE mysql
9. update the password
UPDATE user SET password=(‘ ‘) WHERE user=’root’;
10. exit mysql
11. kill the mysql service running in the first command prompt with
taskkill /F /IM mysqld.exe
12. Start mysql normally
13. from the command prompt or the mysql command line client connect to mysql
mysql -uroot -p
just hit enter for the password
14. update permissions
GRANT all on *.* to root@’localhost’ identified BY ‘newpassword’;
GRANT all on *.* to root@’%’ identified BY ‘newpassword’;
flush PRIVILEGES;
15. exited out of mysql
16. tested new password with
mysql -uroot -p
this time entering the password specified.
Apr 15
A quick way to upgrade mysql on a windows server without using an installer
1. download the mysql-noinstall 32/64 bit version from mysql
2. stop mysql
3. Extract the folder to c:\program files\mysql
4. Renam the MySQL Server 5.1 folder to MySQL Server 5.1_orig
5. rename the extracted folder to MySQL Server 5.1
6. copy C:\program files\mysql\MySQL Server 5.1_orig\data to C:\program files\mysql\MySQL Server 5.1\data
7. copy C:\program files\mysql\MySQL Server 5.1_orig\my.ini to C:\program files\mysql\MySQL Server 5.1\my.ini
8. Start mysql
9. Open a command prompt by selecting Start> run> typing in cmd
10. Change directory to C:\program files\mysql\MySQL Server 5.1_orig\bin by running
cd “C:\program files\mysql\MySQL Server 5.1_orig\bin”
11. upgrade mysql by running
mysql_upgrade
This syncs up the databases with the newly installed version.
Apr 08
partyly taken from
http://www.storegrid.com/forum/viewtopic.php?t=4608&sid=bcf279ac6a6d4e4f4687893715c60e3d
partly taken from
http://www.storegrid.com/forum/viewtopic.php?p=7516
to find out the problem with storegrid:
1) Stop StoreGrid if it is already running.
2) Open a command prompt and go to <STOREGRID_HOME> folder and start StoreGrid by executing the following command: “./bin/StoreGrid > sgoutput.txt”
to fix a corrupt database file
1. Stop StoreGrid
2. Open the terminal window and go to the location
“<StoreGrid_Installation_Dir>/lib/” and copy the ’sqlite.bin’ file to /home/storegrid/Vembu/StoreGrid/data folder.
3. Access the Database base file (sgserver.db) from command line, by executing “./sqlite.bin sgserver.db”.
4. Execute the command “pragma integrity_check;”
5. If the output is ‘ok’ then the database is not corrupted, if not then the database gets corrupted.
6. Quit sqlite application using “.q” command.
7. If sgserver.db is corrupted rename the sgserver.db file available in /home/storegrid/Vembu/StoreGrid/data/ folder to ’sgserver.db.corrupt’.
8. Access the Database base file (sgserver.db.bak) from command line, by executing “./sqlite.bin sgserver.db.bak”. If the output is ‘ok’ then please proceed with step 9 and step 10.
9. Take a another copy of ’sgserver.db.bak’ file and save it as ’sgserver.db.bak.ori’.
10. Copy the ’sgserver.db.bak’ file available in /home/storegrid/Vembu/StoreGrid/data/ folder and save it as ’sgserver.db’ in the same location.
the example I ran myself:
root@data]# ../lib/sqlite.bin sgclient.db
SQLite version 3.5.4
Enter “.help” for instructions
sqlite> pragma integrity_check;
SQL error: malformed database schema
replace database with backup
[root@data]# mv sgclient.db
sgclient.db sgclient.db.bak
[root@data]# mv sgclient.db sgclient.db_bad
[root@data]# cp -p sgclient.db.bak sgclient.db
start database & verify its running
[root@data]# /etc/init.d/storegrid start
Starting StoreGrid!
[root@data]# /etc/init.d/storegrid status
StoreGrid is running as pid 28613 pts/0 00:00:01 StoreGrid
Mar 18
find the device name
fdisk -l
unmount the partition
umount /dev/sde1
run a filesystem check
fsck -n /dev/sde1
remove the journal from the partition
tune2fs -O ^has_journal /dev/sde1
use the fdisk utility on the drive
fdisk /dev/sde
type P to view the paritions
type d to delete the current partition table, if there are more than one type the # of the partition you’re deleting. this will not remove any data
type n to create a new paritional table
type p for primary partition then the number of the partition
for the first and last cylinder do the lowest/highest number if you’re using all of the space
type a to readd the bootable flag then the # of the partition
type w to write to the server and exit fdisk
check the partition
e2fsck -f /dev/sde1
resize the partition to include the new space
resize2fs /dev/sde1
check the files again
fsck -n /dev/sde1
create a new journal for the partition
tune2fs -j /dev/sda1
mount the drive
mount /dev/sde1
verify the space
df -h
or
fdisk -l
If you’re doing this to a doing this to a drive with system files on instead of unmounting and mounting you will reboot into a knopix recovery disk and perform the operations from there.
Mar 12
log into the originating server, open a command prompt and run:
cd %windir%\system32\inetsrv
appcmd add backup backupname
Then copy over %windir%\system32\inetsrv\backup\backupname from the originating server to the server you’re migrating too.
on the ending server open up a command prompt and run:
cd %windir%\system32\inetsrv
appcmd restore backupname
Then update any IPs/file paths in IIS.
Oct 16
This is from http://support.microsoft.com/kb/918992/
Okay, So chances are if you are reading this, you want to migrate an entire instance of SQL. That is pretty simple. You just want to detach all databases, and copy over the MDF and LDF users. But what about the Logins? … Yea … The logins AND Passwords.
Thats where this KB comes in handy.
To transfer the logins and the passwords from the instance of SQL Server on server A to the instance of SQL Server on server B, follow these steps:
USE master
GO
IF OBJECT_ID ('sp_hexadecimal') IS NOT NULL
DROP PROCEDURE sp_hexadecimal
GO
CREATE PROCEDURE sp_hexadecimal
@binvalue varbinary(256),
@hexvalue varchar (514) OUTPUT
AS
DECLARE @charvalue varchar (514)
DECLARE @i int
DECLARE @length int
DECLARE @hexstring char(16)
SELECT @charvalue = '0x'
SELECT @i = 1
SELECT @length = DATALENGTH (@binvalue)
SELECT @hexstring = '0123456789ABCDEF'
WHILE (@i <= @length)
BEGIN
DECLARE @tempint int
DECLARE @firstint int
DECLARE @secondint int
SELECT @tempint = CONVERT(int, SUBSTRING(@binvalue,@i,1))
SELECT @firstint = FLOOR(@tempint/16)
SELECT @secondint = @tempint - (@firstint*16)
SELECT @charvalue = @charvalue +
SUBSTRING(@hexstring, @firstint+1, 1) +
SUBSTRING(@hexstring, @secondint+1, 1)
SELECT @i = @i + 1
END
SELECT @hexvalue = @charvalue
GO
IF OBJECT_ID ('sp_help_revlogin') IS NOT NULL
DROP PROCEDURE sp_help_revlogin
GO
CREATE PROCEDURE sp_help_revlogin @login_name sysname = NULL AS
DECLARE @name sysname
DECLARE @type varchar (1)
DECLARE @hasaccess int
DECLARE @denylogin int
DECLARE @is_disabled int
DECLARE @PWD_varbinary varbinary (256)
DECLARE @PWD_string varchar (514)
DECLARE @SID_varbinary varbinary (85)
DECLARE @SID_string varchar (514)
DECLARE @tmpstr varchar (1024)
DECLARE @is_policy_checked varchar (3)
DECLARE @is_expiration_checked varchar (3)
DECLARE @defaultdb sysname
IF (@login_name IS NULL)
DECLARE login_curs CURSOR FOR
SELECT p.sid, p.name, p.type, p.is_disabled, p.default_database_name, l.hasaccess, l.denylogin FROM
sys.server_principals p LEFT JOIN sys.syslogins l
ON ( l.name = p.name ) WHERE p.type IN ( 'S', 'G', 'U' ) AND p.name <> 'sa'
ELSE
DECLARE login_curs CURSOR FOR
SELECT p.sid, p.name, p.type, p.is_disabled, p.default_database_name, l.hasaccess, l.denylogin FROM
sys.server_principals p LEFT JOIN sys.syslogins l
ON ( l.name = p.name ) WHERE p.type IN ( 'S', 'G', 'U' ) AND p.name = @login_name
OPEN login_curs
FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @type, @is_disabled, @defaultdb, @hasaccess, @denylogin
IF (@@fetch_status = -1)
BEGIN
PRINT 'No login(s) found.'
CLOSE login_curs
DEALLOCATE login_curs
RETURN -1
END
SET @tmpstr = '/* sp_help_revlogin script '
PRINT @tmpstr
SET @tmpstr = '** Generated ' + CONVERT (varchar, GETDATE()) + ' on ' + @@SERVERNAME + ' */'
PRINT @tmpstr
PRINT ''
WHILE (@@fetch_status <> -1)
BEGIN
IF (@@fetch_status <> -2)
BEGIN
PRINT ''
SET @tmpstr = '-- Login: ' + @name
PRINT @tmpstr
IF (@type IN ( 'G', 'U'))
BEGIN -- NT authenticated account/group
SET @tmpstr = 'CREATE LOGIN ' + QUOTENAME( @name ) + ' FROM WINDOWS WITH DEFAULT_DATABASE = [' + @defaultdb + ']'
END
ELSE BEGIN -- SQL Server authentication
-- obtain password and sid
SET @PWD_varbinary = CAST( LOGINPROPERTY( @name, 'PasswordHash' ) AS varbinary (256) )
EXEC sp_hexadecimal @PWD_varbinary, @PWD_string OUT
EXEC sp_hexadecimal @SID_varbinary,@SID_string OUT
-- obtain password policy state
SELECT @is_policy_checked = CASE is_policy_checked WHEN 1 THEN 'ON' WHEN 0 THEN 'OFF' ELSE NULL END FROM sys.sql_logins WHERE name = @name
SELECT @is_expiration_checked = CASE is_expiration_checked WHEN 1 THEN 'ON' WHEN 0 THEN 'OFF' ELSE NULL END FROM sys.sql_logins WHERE name = @name
SET @tmpstr = 'CREATE LOGIN ' + QUOTENAME( @name ) + ' WITH PASSWORD = ' + @PWD_string + ' HASHED, SID = ' + @SID_string + ', DEFAULT_DATABASE = [' + @defaultdb + ']'
IF ( @is_policy_checked IS NOT NULL )
BEGIN
SET @tmpstr = @tmpstr + ', CHECK_POLICY = ' + @is_policy_checked
END
IF ( @is_expiration_checked IS NOT NULL )
BEGIN
SET @tmpstr = @tmpstr + ', CHECK_EXPIRATION = ' + @is_expiration_checked
END
END
IF (@denylogin = 1)
BEGIN -- login is denied access
SET @tmpstr = @tmpstr + '; DENY CONNECT SQL TO ' + QUOTENAME( @name )
END
ELSE IF (@hasaccess = 0)
BEGIN -- login exists but does not have access
SET @tmpstr = @tmpstr + '; REVOKE CONNECT SQL TO ' + QUOTENAME( @name )
END
IF (@is_disabled = 1)
BEGIN -- login is disabled
SET @tmpstr = @tmpstr + '; ALTER LOGIN ' + QUOTENAME( @name ) + ' DISABLE'
END
PRINT @tmpstr
END
FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @type, @is_disabled, @defaultdb, @hasaccess, @denylogin
END
CLOSE login_curs
DEALLOCATE login_curs
RETURN 0
GO
Note This script creates two stored procedures in the master database. The two stored procedures are named the sp_hexadecimal stored procedure and the sp_help_revlogin stored procedure.
EXEC sp_help_revlogin
The output script that is generated by the sp_help_revlogin stored procedure is the login script. This login script creates the logins that have the original Security Identifier (SID) and the original password.
Jun 17
taken from:
http://blogs.sun.com/danielc/entry/a_little_script_to_clone and http://hsukumar.wordpress.com/2008/05/14/esx-clone-without-virtual-center/
1. Log into the ESX server using the vmware infrastructure client and turn off the server you want to clone. 2. SSH into the server, sudo to root
3. run: /clone.sh <origina> <clone> example: /clone.sh “App Server 1″ “App Server 2″
4. Once the clone process finishs go back to the Vmware infrastructure client and create a new VM.
5. Select Custom configuration then browse through the options setting anything you’d like until you get to Select a disk. Browse to the vmdk that you cloned and select it, then select finish.
6. Power on the VM, log in and change the IP
The script:
SOURCEVM=$1
TARGETVM=$2
DATASTORE=/vmfs/volumes/MY-VM-STORE
mkdir $DATASTORE/”$2″
vmkfstools -i $DATASTORE/”$1″/”$1″.vmdk $DATASTORE/”$2″/”$2″.vmdk
Apr 21
suphp configuration:
download a copy of an rpm from http://dag.wieers.com/rpm/packages/mod_suphp/
after the rpm is installed install
Plesk
1) make following changes to /etc/suphp.conf:
; docroot=/ [handlers] ;Handler for php-scripts ;x-httpd-php=php:/usr/bin/php suphp-script=php:/usr/bin/php-cgi ;Handler for CGI-scripts x-suphp-cgi=execute:!self
2) make following changes to /etc/httpd/conf.d/suphp.conf (these are the most important changes, as they’ll prevent other vhosts from using suPHP or just breaking randomly)
suPHP_Engine off #AddHandler x-httpd-php .php #AddHandler x-httpd-php .php .php4 .php3 .phtml
3) create /var/www/vhosts/<domain>/conf/vhost.conf as follows:
<Directory /var/www/vhosts/<domain/httpdocs> suPHP_Engine on suPHP_UserGroup <user> <group> suPHP_ConfigPath /var/www/vhosts/<domain>/etc AddHandler suphp-script .php </Directory>
4) create /var/www/vhosts/<domain>/etc and copy /etc/php.ini to it
5) create var/www/vhosts/<domain>/tmp and update session save path in php.ini
6) run /usr/local/psa/admin/sbin/websrvmng -av, and restart apache
Not plesk:
remove the /etc/httpd/conf.d/suphp.conf file and did everything in the httpd.conf folder
These are the lines that are needed outside the vhosts
LoadModule suphp_module modules/mod_suphp.so suPHP_Engine on
These are the lines needed inside of the vhosts
<Directory /var/www/html/<domain>/httpdocs>
php_admin_flag engine off
suPHP_Engine on
suPHP_UserGroup user user
suPHP_ConfigPath /var/www/html/mobile/etc/php.ini
SuPHP_AddHandler suphp-script
AddHandler suphp-script .php
</Directory>