Dear Community !
Today, I just make a test with bash script to backup mysql data. You can take this script to play around with it. Thanks!
================================
#!/bin/bash
TIMESTAMP=$(date +"%F")
BACKUP_DIR="/path/db_mysql/$TIMESTAMP"
MYSQL_USER="msqluser"
MYSQL=/usr/bin/mysql
MYSQL_PASSWORD="123456789"
MYSQLDUMP=/usr/bin/mysqldump
mkdir -p "$BACKUP_DIR/mysql"
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"`
for db in $databases; do
$MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/mysql/$db.gz"
done
========================
Hope you enjoy!
Wednesday, August 24, 2016
Thursday, July 28, 2016
Monitor Postgres Guide line For postgresql adminstration:
+ To track service of postgres :
- ps -ef | grep postgres
+ top :
- top -c -u postgres
+ iostat : Check device status
- iostat 2 5
+ netstat : information about current network connection
- netstat -an | grep LISTEN
- netstat -an | grep LISTEN | grep tcp
- netstat -an | grep LISTEN | grep PGSQL
+ pg_stat_activilty : to track number of connections, query activity,...
+ pg_stat_replication : to monitor postgres clustering
+ pg_stat_archvier : to monitor archive files , log files,....
+ pg_stat_bgwriter: checking perform : like check_piont time. ...
+ pg_stat_database : to check status for databases,....
+ pg_stat_all_tables : to check status for tables,....
+ pg_stat_all_indexes : to track indexes,...
+ pg_stat_system_indexes : to check status for indexes,...
+ pg_stat_user_indexes : to track user indexes,....
+ pg_stat_database_conflicts : to check status for conflic like tables,....
**** Useful Queries ****
+ Show all current connections:
select * from pg_stat_activity;
+ Show all waiting queries:
select * from pg_stat_activity where waiting='t';
+ Show top 3 longest running queries:
select datname,usename,now() - query_start as query_runtime from pg_stat_activity order by 3 desc limit 3;
+ du -hcs data/* : Disk space usage
+ Huge Pages
# grep ^Huge /proc/meminfo
- ps -ef | grep postgres
+ top :
- top -c -u postgres
+ iostat : Check device status
- iostat 2 5
+ netstat : information about current network connection
- netstat -an | grep LISTEN
- netstat -an | grep LISTEN | grep tcp
- netstat -an | grep LISTEN | grep PGSQL
+ pg_stat_activilty : to track number of connections, query activity,...
+ pg_stat_replication : to monitor postgres clustering
+ pg_stat_archvier : to monitor archive files , log files,....
+ pg_stat_bgwriter: checking perform : like check_piont time. ...
+ pg_stat_database : to check status for databases,....
+ pg_stat_all_tables : to check status for tables,....
+ pg_stat_all_indexes : to track indexes,...
+ pg_stat_system_indexes : to check status for indexes,...
+ pg_stat_user_indexes : to track user indexes,....
+ pg_stat_database_conflicts : to check status for conflic like tables,....
**** Useful Queries ****
+ Show all current connections:
select * from pg_stat_activity;
+ Show all waiting queries:
select * from pg_stat_activity where waiting='t';
+ Show top 3 longest running queries:
select datname,usename,now() - query_start as query_runtime from pg_stat_activity order by 3 desc limit 3;
+ du -hcs data/* : Disk space usage
+ Huge Pages
# grep ^Huge /proc/meminfo
Friday, July 22, 2016
Install Oracle in silent mode 11G Release 2 (11.2) on OEL6
Silent mode installation allows to configure necessary Oracle components without using graphical interface nor any interaction with end user. It’s very useful method especially when you want to prepare standard installation using shell scripts.
Reference Link: http://dbaora.com/install-oracle-in-silent-mode-11g-release-2-11-2/
Reference Link: http://dbaora.com/install-oracle-in-silent-mode-11g-release-2-11-2/
Lynis - Security Tool for Audit and Hardening Linux / Unix Systems
System administrator must have known about the importance of security. Maintaining servers are not just make the server is up and running but it should be secure too. Security is not coming by default. We need to tune-up the systems to fit our needs. Since security has a wide coverage, sometimes its easy for us to miss something. Because of that, there is a security tool that can remind system administrators what should they do to secure and harden their systems.
Reference Link :http://linoxide.com/how-tos/lynis-security-tool-audit-hardening-linux/
Reference Link :http://linoxide.com/how-tos/lynis-security-tool-audit-hardening-linux/
Securing and Hardening Red Hat Linux Production Systems
Focus of this Article
This Linux Security HOWTO is intended for a technical audience, Linux system administrators, and security people in corporations and organizations that have to use commercial Linux distributions for their production environment. If you are a Linux expert then you may find familiar material here, but you will have difficulties to find documentation on various topics like restricting su access to system and shared accounts only as covered in this article, see Restricting su Access to System and Shared Accounts.
If you need to make Linux production systems compliant with various audit requirements, then this article should offer a good baseline and starting point. The main objective of this Linux Security guide is to discuss basic Linux security requirements including account policies for production systems that are being audited. This document covers various system services like SSH which are usually enabled and required on all Linux production servers. But it does not cover services or applications like Apache, Samba etc., since these applications/services are usually not needed across all Linux servers and should therefore not be installed on all systems. In fact, these applications warrant their own security HOWTO. Also, this article does not cover security features that require kernel patching. This is not an option for most companies due to vendor support issues.
Reference Link: http://www.puschitz.com/SecuringLinux.shtml
Documenting security best practices - XCCDF introduction
When I have some free time, I try to work on a Gentoo Security Benchmark which not only documents security best practices (loosely based on the Gentoo Security Handbook which hasn't seen much updates in the last few years) but also uses the SCAP protocols. This set of protocols allows security administrators to automate and document many of their tasks, and a security best practices guide is almost a must-have in any organization. So I decided to do a few write-ups about these SCAP protocols and how I hope to be using them more in the future.
In this post, I'm going to focus on a very simple matter: documenting. SCAP goes much, much beyond documenting, but I'll discuss those various features in subsequent posts. The end goal of the series is to have a best practice document for PostgreSQL.
To document the secure state of a component, it is important to first have an idea about what you are going to document. Some people might want to document best practices across many technologies so that there is a coherent, single document explaining the security best practices for the entire organization. In my opinion, that is not manageable in the long term. We tried that with the Gentoo Security Handbook, but you quickly start wrestling with the order of chapters, style concerns and what not. Also, some technologies will be much more discussed in depth than others, making the book look "unfinished".
Personally, I rather focus on a specific technology. For instance: Hardening OpenSSH (very much work in progress - the rules are generated automatically for now and will be rewritten in the near future). It talks about a single component (OpenSSH) allowing the freedom for the author to focus on what matters. By providing security best practices on these component levels, you'll create a set of security best practices that can often be reused. This is what the Center for Internet Security is doing with its benchmarks: popular technologies are described in detail on how to configure them to be more secure.
Once you know what technology you want to describe, we need to consider how this technology is used. Some technologies are very flexible in their setup, and might have different security setups depending on their use. For instance, an OpenLDAP server can be used internally as a public address book, or disclosed on the Internet in a multi-replicated setup with authentication data in it. The security best practices for these deployments will vary. The XCCDF (Extensible Configuration Checklist Description Format)standard allows authors to write a single guide, while taking into account the different deployment approaches through the use of
Profile settings.
In XCCDF,
Profiles allow for selectively enabling or disabling document fragments (called Groups) and checks (called Rules - I will post about checks later) or even change values (like the minimum password length) depending on the profile. A document can then describe settings with different profiles depending on the use and deployment of the technology. Profiles can also inherit from each other, so you can have a base (default) security conscious setup, and enhance it through other profiles.
Next to the "how", we also need to consider the structure we want for such a best practice:
- We will have rules in place for the deployment of PostgreSQL itself. These rules range from making sure a stable, patched version is used, to the proper rights on the software files, partitioning and file system rules and operating system level requirements (such as particular kernel parameters).
- We will also have rules for each instance. We could plan on running multiple PostgreSQL instances next to each other, so these rules are distinct from the deployment rules. These rules include settings on instance level, process ownership (in case of running PostgreSQL as different service user), etc.
- We might even have rules for databases and users (roles) in the database.
It might make sense to split the best practices in separate documents, such as one for PostgreSQL infrastructure (which is database-agnostic) and one for PostgreSQL databases (and users). I would start with one document for the technology if I was responsible for the entire definition, but if this responsibility is not with one person (or team), it makes sense to use different documents. Also, as we will see later, XCCDF documents can be "played" against a target. If the target is different (for infrastructure, the target usually is the host on which PostgreSQL is installed, whereas for the database settings the target is probably the PostgreSQL instance itself) I would definitely have the definitions through separate profiles, but that does not mean the document needs to be split either.
Finally, documenting a secure best practice also involves keeping track of the references. It is not only about documenting something and why you think this is the best approach, but also about referring readers to more information and other resources that collaborate your story. These can be generic control objectives (such as those provided by the open security architecture) or specific best practices of the vendor itself or third parties.
At the end, for a PostgreSQL security guide, we would probably start with:
Hardening PostgreSQL
+- Basic setup
+- Instance level configuration
| +- Pre-startup configuration
| `- PostgreSQL internal configuration
+- Database recommendations
`- User definitions
Profile-wise, I probably would need an infrastructure profile, an instance profile, a user profile and a database profile. I might even have profiles for the different roles (functional account, administrator and end user profiles which inherit from the user profile) as they will have different rules assigned to them.
Wednesday, January 14, 2015
Performance Tuning PostgreSQL
It's a broad topic, so here's lots of stuff for you to read up on:
And when you've exhausted those options: add more memory, faster disk-subsystem etc. Hardware matters, especially on larger datasets.
And of course, read all the other threads on postgres/databases.
- EXPLAIN and EXPLAIN ANALYZE is extremely useful for understanding what's going on in your db-engine
- Make sure relevant columns are indexed
- Make sure irrelevant columns are not indexed (insert/update-performance can go down the drain if too many indexes must be updated)
- Make sure your postgres.conf is tuned properly
- Know what work_mem is, and how it affects your queries (mostly useful for larger queries)
- Make sure your database is properly normalized
- VACUUM for clearing out old data
- ANALYZE for updating statistics (statistics target for amount of statistics)
- Persistent connections (you could use a connection manager like pgpool or pgbouncer)
- Understand how queries are constructed (joins, sub-selects, cursors)
- Caching of data (i.e. memcached) is an option
And when you've exhausted those options: add more memory, faster disk-subsystem etc. Hardware matters, especially on larger datasets.
And of course, read all the other threads on postgres/databases.
Tuesday, January 13, 2015
PostgreSQL cursors
Question:
I am trying to learn basic cursors using PostgreSQL. This is my script:
DECLARE cur_employees CURSOR FOR
SELECT *
FROM employee
CLOSE cur_employees
I want to traverse the list and output those which are active. Where should I start?
Answer:
You very rarely want to explicitly use cursors at all in PostgreSQL,
even when processing query results in plpgsql. This is a marked contrast
from many other SQL databases where they are used almost all the time.
In plpgsql you could simply write something like:
With PostgreSQL from 9.0, you can simply drop into executing plpgsql using a "DO" block. For prior versions, you need to create a function and select it. If you're looking for the PostgreSQL equivalent of, for example, iterating through a result with a cursor on SQL Server, that's what it is. Note that iteration etc. are not part of the SQL dialect, only part of plpgsql (or any of the other emebedded languages).
The "DECLARE CURSOR xxx" syntax at the SQL level can be used like this:
In plpgsql you could simply write something like:
DECLARE
employee%rowtype emp;
BEGIN
FOR emp IN SELECT * FROM employee LOOP
IF emp.active THEN
RAISE INFO 'Active: %', emp.employee_id
END IF;
END LOOP;
END
In the above, the plpgsql language handler deals with opening, binding, fetching and closing itself.With PostgreSQL from 9.0, you can simply drop into executing plpgsql using a "DO" block. For prior versions, you need to create a function and select it. If you're looking for the PostgreSQL equivalent of, for example, iterating through a result with a cursor on SQL Server, that's what it is. Note that iteration etc. are not part of the SQL dialect, only part of plpgsql (or any of the other emebedded languages).
The "DECLARE CURSOR xxx" syntax at the SQL level can be used like this:
DECLARE cur_employees CURSOR FOR SELECT * FROM employee;
FETCH NEXT FROM cur_employees;
// etc..
CLOSE cur_employees;
This can be used to carefully get just part of the query result set.
However, it's unusual to use these, since usually your client driver
will provide some sort of functionality to do this (e.g. scrollable
result sets in JDBC). You can also return cursors from functions similar
to Oracle, although again that's a comparatively rare use case.Friday, December 5, 2014
how to do a SQL insert with a value with an apostrophe in it
INSERT INTO Person
(First, Last)
VALUES
('Joe', 'O''Brien')
/\
here
Monday, November 3, 2014
PostgreSQL Error 42501: Permission Denied for Schema
I appear to have gotten it working. I looked back over all of the
permission settings on the schema, except that this time I went back
through all of the "Default Privileges" as well. I set my "systemusers"
group to have
So, apparently I DID overlook something rather important. Even with all of the individual permission settings I had assigned on the specific objects, those default privileges were still not set the way they needed to be. Lesson learned
SELECT on tables and sequences, EXECUTE on functions and USAGE on types. When I tested again, my stored procedure ran correctly and created my profile record in the database as expected.So, apparently I DID overlook something rather important. Even with all of the individual permission settings I had assigned on the specific objects, those default privileges were still not set the way they needed to be. Lesson learned
Postgres INSERT ERROR: permission denied for schema public
|
Assuming the username is
testing, you probably want to do:
Note about granting ALL PRIVILEGES: you don't say on what this GRANT command was applied. Assuming it was ON DATABASE..., it just means CONNECT, CREATE and TEMP privileges, nothing about the public schema or any other contained object, which is why it "doesn't work".EDIT: when that's not sufficient If the tables referenced by the foreign keys are not owned by testing, their owner needs also to have the USAGE privilege on the schema in order to look up the referenced tables.It's not obvious from the result of \dp (the result of \d would tell for sure) but if category is owned by super and that user also has no privilege on the schema, you'd need to assign it with:
|
Friday, October 24, 2014
how to get active frame on JDesktopPane
Use JDekstopPane.getSelectedFrame() method (From doc: currently active JInternalFrame in this JDesktopPane, or null if no JInternalFrame is currently active.) or
JDesktopPane.getAllFrames() to get list of all JInternalFrames currently displayed in the desktop and check isSelected() method.
Monday, September 29, 2014
how to check number in java
Hi all, this simple code to check number that I wrote with java code.
public boolean isNumeric(String st){
try{
double d = Double.parseDouble(st);
}catch(NumberFormatException e){
return false;
}
return true;
}
Please enjoy and sharing your ideas!
public boolean isNumeric(String st){
try{
double d = Double.parseDouble(st);
}catch(NumberFormatException e){
return false;
}
return true;
}
Please enjoy and sharing your ideas!
How to check dot(.) in java code
Hi everyone, today I want to show you how to check dot(.) by using java code. The purpose of this code, we want to allow dot one time when we trigger it. example like calculator ...
Please enjoy with my code and then pls you help to comment me to improve our knowledge each other. Thanks Advance!
public boolean checkDot(String st){
char ch[] = st.toCharArray();
for(int i=0;i<ch.length;i++)
if(ch[i] =='.')
return true;
return false;
}
This code, I allow to pass arguments as String. But you can modify it by your needs. Thanks!
Please enjoy with my code and then pls you help to comment me to improve our knowledge each other. Thanks Advance!
public boolean checkDot(String st){
char ch[] = st.toCharArray();
for(int i=0;i<ch.length;i++)
if(ch[i] =='.')
return true;
return false;
}
This code, I allow to pass arguments as String. But you can modify it by your needs. Thanks!
Thursday, September 11, 2014
How to list directories, subdirectories and files using java
Hi everyone, I welcome to my post. Today I want to show you some codes using java language to list directories, subdirectories, and files. You can see my as below:
package com.saretsothea.files.classwork;
import java.io.File;
import java.util.Scanner;
/**
*
* @author Sout Saret
*/
public class ListFiles{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
String folder;
System.out.print("Please the path of folder:");
folder =sc.nextLine();
System.out.println("List all directories, subdirectries and files:");
File f = new File(folder);
System.out.println(f.getName());
listFile(folder);
}
public static void listFile(String folder){
try{
File f = new File(folder);
File[] listOfFiles = f.listFiles();
for(int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
System.out.println("--" + listOfFiles[i].getName());
} else if (listOfFiles[i].isDirectory()) {
System.out.println("-"+listOfFiles[i].getName());
listFile(listOfFiles[i].getAbsolutePath());
}
}
}catch(NullPointerException e){}
}
}
Thanks for reading!!!!!!!!!!!!!!
package com.saretsothea.files.classwork;
import java.io.File;
import java.util.Scanner;
/**
*
* @author Sout Saret
*/
public class ListFiles{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
String folder;
System.out.print("Please the path of folder:");
folder =sc.nextLine();
System.out.println("List all directories, subdirectries and files:");
File f = new File(folder);
System.out.println(f.getName());
listFile(folder);
}
public static void listFile(String folder){
try{
File f = new File(folder);
File[] listOfFiles = f.listFiles();
for(int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
System.out.println("--" + listOfFiles[i].getName());
} else if (listOfFiles[i].isDirectory()) {
System.out.println("-"+listOfFiles[i].getName());
listFile(listOfFiles[i].getAbsolutePath());
}
}
}catch(NullPointerException e){}
}
}
Thanks for reading!!!!!!!!!!!!!!
Monday, July 14, 2014
How to convert a numeric value into English words in Excel
How to create the sample function Called SpellNumber
- Start Microsoft Excel.
- Press ALT+F11 to start the Visual Basic Editor.
- On the Insert menu, click Module.
- Type the following code into the module sheet.
Option Explicit
'Main Function
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
' String representation of amount.
MyNumber = Trim(Str(MyNumber))
' Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, ".")
' Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
"00", 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If
Count = 1
Do While MyNumber <> ""
Temp = GetHundreds(Right(MyNumber, 3))
If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
Dollars = "No Dollars"
Case "One"
Dollars = "One Dollar"
Case Else
Dollars = Dollars & " Dollars"
End Select
Select Case Cents
Case ""
Cents = " and No Cents"
Case "One"
Cents = " and One Cent"
Case Else
Cents = " and " & Cents & " Cents"
End Select
SpellNumber = Dollars & Cents
End Function
' Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) <> "0" Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function
' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result = "" ' Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...
Select Case Val(TensText)
Case 10: Result = "Ten"
Case 11: Result = "Eleven"
Case 12: Result = "Twelve"
Case 13: Result = "Thirteen"
Case 14: Result = "Fourteen"
Case 15: Result = "Fifteen"
Case 16: Result = "Sixteen"
Case 17: Result = "Seventeen"
Case 18: Result = "Eighteen"
Case 19: Result = "Nineteen"
Case Else
End Select
Else ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
Case 4: Result = "Forty "
Case 5: Result = "Fifty "
Case 6: Result = "Sixty "
Case 7: Result = "Seventy "
Case 8: Result = "Eighty "
Case 9: Result = "Ninety "
Case Else
End Select
Result = Result & GetDigit _
(Right(TensText, 1)) ' Retrieve ones place.
End If
GetTens = Result
End Function
' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four"
Case 5: GetDigit = "Five"
Case 6: GetDigit = "Six"
Case 7: GetDigit = "Seven"
Case 8: GetDigit = "Eight"
Case 9: GetDigit = "Nine"
Case Else: GetDigit = ""
End Select
End Function
Thursday, May 29, 2014
Permission denied in PostgreSQL
You've granted
Can be done per schema:
Don't forget to
CREATE, CONNECT, and TEMPORARY privileges on the database to myuser but you haven't granted SELECT and INSERT table privileges yet. You'll need something like:GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO myuser;
In addition you need privileges on sequences if you have any serial columns or other column defaults drawing from sequences. Generally, the USAGE privilege is be enough for INSERT operations to work, but since you asked to "give all rights":GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO myuser;
You will probably want to grant DEFAULT PRIVILEGES, too. So your administrator can access future objects automatically, too.Can be done per schema:
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO administrator;
If you omit the schema, it applies to the whole database:ALTER DEFAULT PRIVILEGES GRANT ALL ON TABLES TO administrator;
Only applies to objects created by the role specified (defaulting to the role that executes this command):ALTER DEFAULT PRIVILEGES FOR staff GRANT IN SCHEMA public ... ;
Available since PostgreSQL 9.0.Don't forget to
GRANT privileges on SEQUENCES in addition if you have any. (For instance as source for default values in a serial column.)
ERROR: permission denied for sequence using PostgreSQL
Since PostgreSQL 8.2 you have to use:
GRANT USAGE, SELECT ON SEQUENCE cities_id_seq TO user;
GRANT USAGE - For sequences, this privilege allows the use of the currval and nextval functions.Thursday, May 22, 2014
Granting access to all tables for a user on PostgreSQL Database
First, you have to be able to connect to the database in order to run queries. This can be achieved by
REVOKE CONNECT ON DATABASE your_database FROM PUBLIC;
GRANT CONNECT
ON DATABASE database_name
TO user_name;
The REVOKE is necessary becauseThe key word PUBLIC indicates that the privileges are to be granted to all roles, including those that might be created later. PUBLIC can be thought of as an implicitly defined group that always includes all roles. Any particular role will have the sum of privileges granted directly to it, privileges granted to any role it is presently a member of, and privileges granted to PUBLIC.If you really want to restrict your user to DML statements, then you have a little more to do:
REVOKE ALL
ON ALL TABLES IN SCHEMA public
FROM PUBLIC;
GRANT SELECT, INSERT, UPDATE, DELETE
ON ALL TABLES IN SCHEMA public
TO user_name;
These assume that you will have only one schema (which is named 'public' by default).Wednesday, May 21, 2014
Configuring MS SQL Server for Remote Access
Problem:
A Microsoft SQL instance cannot be accessed remotely through ODBC, Visual Studio, or SQL Server Management Studio connection.Resolution:
(applies to MS SQL 2005, 2008, 2008 R2, and 2012)The Windows firewall is usually the culprit in these scenarios. Open TCP port 1433 for the service itself, and 1434 if you need to use the SQL Browser service. Read this article to learn how to Open an Inbound Custom Allow Rule in Windows Firewall.
- Open cliconfg from a RUN prompt and make sure TCP/IP is an enabled protocol.
For SQL 2005/2008/2008 R2: Check the Services tool, Start > Administrative Tools > Services, to see that the service named SQL Server (MSSQLSERVER) is started.
For MS SQL 2012: Use the Windows key or hover over the left lower corner of the desktop and select Administrative Tools, then Services to see that the service named SQL Server (MSSQLSERVER) is started.
- Ensure that you are using the correct credentials to authenticate. The default SQL administrator account is named sa and if you built the server from one of our server images with MSSQL pre-installed, the password will be in a text file on the root of the C partition.
- Use netstat –an from the command prompt to verify that the server is listening for SQL traffic on the correct ports.
- If the server is not listening for SQL traffic on the correct ports, use SQL Server Configuration Manager to change the ports.
- For MS SQL 2005/2008/2008 R2, go to Start > All Programs > Microsoft SQL Server 2005 (or 2008/2008 R2) > Configuration Tools > SQL Server Configuration Manager.
For MS SQL 2012: Use the Windows key or hover over the left lower corner of the desktop and select All Programs > Microsoft SQL Server 2012 > Configuration Tools > SQL Server Configuration Manager.
- Open the + next to SQL Server Network Configuration.
- Right-click TCP/IP and select Properties.
- Select IP Addresses.
- All TCP ports mentioned on all interfaces should be 1433. Change this to reflect the correct port number and restart the SQL services.
- For MS SQL 2005/2008/2008 R2, go to Start > All Programs > Microsoft SQL Server 2005 (or 2008/2008 R2) > Configuration Tools > SQL Server Configuration Manager.
For MS SQL 2012: Use the Windows key or hover over the left lower corner of the desktop and select All Programs > Microsoft SQL Server 2012 > Configuration Tools > SQL Server Configuration Manager.
- If you are using named instances when installing SQL, giving you the ability to host multiple SQL versions or service types, you will have to specify the name of the SQL instance when connecting rather than just using the server’s name or IP. If you have created a named instance, you will need to access it by appending the name to the server’s name or IP, following a backslash (e.g. 12.34.56.78\SQLINSTANCENAME or SQLSERVERNAME\SQLINSTANCENAME).
Subscribe to:
Posts (Atom)