In the process of using the Sybase database, we often encounter locks in the Sybase Database System. In most cases, users must log on to the system as Super Users to process the process. To ensure the security of the Sybase Database System, the superuser password is usually in the hands of the database administrator.
When the above situation occurs, if the database administrator is absent from the site or cannot handle the problem in other ways, the user can verbally inform the password to solve the urgent problem, however, the security of the database system is undoubtedly seriously threatened. Restarting the Sybase database system is also a solution. However, this approach may cause data loss in the database, this method may even cause the user database to crash.
If you can set user permissions so that common users can process the process without having to know the Super User password of the Sybase Database System, it is undoubtedly the best solution to the above problems. Now, I will give you a detailed introduction of the entire process for the above situation for your reference. Of course, you can set a common user password based on your needs, or limit more content to process processes in the database system. The specific process is as follows.
1. Write a program in C language as follows:
# Include <stdlib. h>
# Include <string. h>
# Include <fcntl. h>
# Include <time. h>
# Include <sys/types. h>
Char* Passwd ()/* Password required by common users: simple encrypted string */
{
Struct Tm* Tp;
LongSecs;
Char* Buff;
Buff = (Char*) Malloc (30 );
Secs = time ((Long*) 0 );
Tp = localtime (& secs );
Sprintf (buff,"% 02d % 02d % d", Tp-> tm_mon + 1 + 9, tp-> tm_mday + 2, 8 );
Return(Buff );
}
Main ()
{
CharStr1 [80], str2 [80];
IntI;
Printf ("Passwd :");
System ("Stty-echo");/* Do Not Display */
Gets (str1 );
System ("Stty echo");
For(I = 3; I <9; I + +) str2 [I-3] = str1 [I];/* Input 6 characters in length */
Str2 [6] ='';
If(Strcmp (str2, passwd ())){
Printf ("passwd error!
");
Exit (1 );
}
Setuid (0 );
System ("/Sybase/atuo/sybase_kill");
Printf ("
");
}
Then compile.
# Cc c. c-o kill-spid
2. Set the user's "s" permission for the generated target file
# Chmod u + s obj-name
3. Place the target file in any directory of the execution user
For example, the tmp directory
4. Execute the sybase-kill file.
The execution file "sybase-kill" should be stored in a directory that only allows access to the file and set its permissions. For example, only Sybase users can read and write data.
# mkdir /sybase/auto
#chmod 700 /sybase/atuo
#chmod g+t /sybase/atuo
#chown sybase:sybase /sybase/atuo
#cd /sybase/atuo
5. The content of the sybase-kill file is as follows.
Trap''1 2 3 9 15 # Set the blocked signal to prevent interruption.
ForPid in 'echo "set nocount on
Select distinct blocked from master... sysprocesses
Where blocked> 0
Go"| Isql-Uaaa-Paaaaaa-w200-SFEBS | sed"1, 2d "'
Do
Echo"Kill"$ Pid
Isql-Usa-w200-Sserv_name <EOF
Password123321
Kill $ pid
Go
EOF
Done
Echo"OK"
The above content will process all blocked processes, whether or not it is caused by it. Of course, you can also find out who caused the blocking and then process the process by modifying the content of its "sybase-kill" file.
Install and configure Sybase ASE for Linux
Two cases of Sybase Database repair
Sybase Database Engine running methods
How to port a database from Sybase to SQL Server
Popularity of Sybase SQL Server logs