I just installed SQL Server 2008, and I wanted to use the command editor to execute queries.
To do that I opened the command prompt, and I typed
Sqlcmd -S Serverinstance
but I got an error saying :
Named Pipes Provider: Could not open a connection to SQL Server [53].
Sqlcmd : erreur : Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Sqlcmd : erreur : Microsoft SQL Server Native Client 10.0 : Login timeout expired
What should I do to get it connected to the server so I can proceed?
Thank you :D.
(This one is going to sounds silly) my problem was that I wasn't using capital 'S'
Eg:
C:\> SQLCMD -S localhost\sqlexpress
You need to either use the integrated-security approach of using your Windows credentials to connect to SQL Server by specifying -E as an option:
C:\> SQLCMD -S Serverinstance -E
or then you need to define a user/password set to achieve a SQL Server login:
C:\> SQLCMD -S Serverinstance -U (login in) -P (password)
All the many SQLCMD parameters are well-documented on MSDN SQL Server Books Online!
The server you are specifying cannot be found or is not accessible. so either the server is wrong (have you spelt it correctly) or you are not specifying it correctly or it is not accessible from your machine.
After you've got that right, you will need to specify a username/password or a -E command qualifier for a Trusted Connection. You may also need to specify the database with a -d qualifier.
You can get help by typing
Sqlcmd -?
Related
How do I configure the MySQL 8.0.15 shell. I just downloaded it and I am already having problems.
When I run the shell program I always have to switch from MySQL JS to MySQL SQL
I always have to reconnect using \connect root#localhost
I would like to open the MySQL shell and just get to work without having to do those two things.
If you start the shell with mysqlsh --sql --uri=myname#localhost it will accept SQL commands directly.
If you need only to use SQL you may wish to consider using the ancient and honorable mysql command line client program. mysql -h localhost -u myname
I'm a little green at this, and I hope the issue I'm having is a simple one...edit: new information at bottom
I need to make a connection to a remote mysql (Amazon RDS) database.
After following a few tutorials, I have unixodbc and libmyodbc installed and configured on the client, but when I try to connect via isql, I get the error
[08S01][unixODBC][MySQL][ODBC 5.1 Driver]Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[ISQL]ERROR: Could not SQLConnect
The most confusing part about this error is that I'm not trying to connect to a local database, but rather to a remote one. I do not have a mysql.sock file on the client...this isn't the issue though is it?
I'm sensing a configuration error but I'm just not sure what it could be.
If I run odbcinst -j then the output is:
DRIVERS............: /etc/unixODBC/odbcinst.ini
SYSTEM DATA SOURCES: /etc/unixODBC/odbc.ini
USER DATA SOURCES..: /root/.odbc.ini
The content of /etc/unixODBC/odbcinst.ini is:
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib64/libmyodbc5.so
Setup = /usr/lib64/unixODBC/libodbcmyS.so
UsageCount = 5
[MySQL ODBC 515 Driver]
Description = ODBC 5.515 for MySQL
DRIVER = /usr/lib64/libmyodbc5-5.1.5.so
SETUP = /usr/lib64/unixODBC/libodbcmyS.so
UsageCount = 3
Please note that I had to make up this configuration myself, I did a find for libmyodbc* and found these two .so files, thus set up a driver for each of them. A search for libodbcmyS* yields:
/usr/lib64/unixODBC/libodbcmyS.so.1
/usr/lib64/unixODBC/libodbcmyS.so
/usr/lib64/unixODBC/libodbcmyS.so.1.0.0
So, I don't know what else that configuration could be.
The content of /etc/unixODBC/odbc.ini is:
[target_db]
Driver = MySQL
Server = [servername.com]
Port = 3306
Database = [databasename]
Option = 2
User = [username]
Password = [password]
I've tried different options in "Driver", changing it from MySQL, to MySQL ODBC 515 Driver, to the path to the .so file (eg: /usr/lib64/libmyodbc5.so) and all yield the same result.
I'm running:
odbcinst -i -d -f /etc/unixODBC/odbcinst.ini
Followed by:
odbcinst -i -s -l -f /etc/unixODBC/odbc.ini
Followed by:
odbcinst -s -q
Which prints out the name of my connection, ie [target_db]
Then, I try the connect:
isql -v target_db user password
or just
isql -v target_db
and get the error shown above.
Anyone happen to know what I'm doing wrong here? Thanks a bunch-
EDIT:
Wanted to mention that I'm able to connect to the database from this server using the mysql command line tools.
I installed a local mysql database, and I'm able to connect to this using isql. It seems to be ignoring my odbc.ini file entirely, i have to enter a name with the command, ie isql -v test-database, but it still tries to connect to localhost despite my settings.
I feel as though I've tried everything but will keep at it and will post if i find a solution.
You could try to connect using the ip of your server instead of the dns entry on the "Server" line of odbc.ini.. Have you verified the driver is installed with phpinfo()?
Try to set the environment variable ODBCINI with the path of your odbc.ini file.
Keep in mind that the odbc.ini file you point to must be "write-accessible" by the user that is running the program (i.e. the user must have permissions to write in this file).
chmod g+w .odbc.ini did it for me since we run the DB with ORACLE-Start and the crs-User seems to be in charge
I'm trying to configure a new connection through SSH tunnel.
But on the server, the command mysql does not exists. I have my own compilation called custo-mysql.
I mean, when I'm on the server, I use the following command :
$ custo-mysql -u root -pmypassword
How can I tell workbench to use custo-mysql and not mysql ?
mysql (and your custo-mysql) is a client for the server. Workbench is a client as well, so it doesn't need to use that custo-mysql thing. It just connects to your server.
Basically, on your server you have a "mysqld" running: a mysql server. Your commans custo-mysql connects to that server as a sort of interface. Workbench has the exact same function, so it should work if your networking/tunneling etc is correct.
As #Nanne already mentioned, you don't need the mysql client to connect to your MySQL server using Workbench.
I would just like to point out that Workbench does use the mysql command line client for importing databases in the Admin / Data Import/Restore section. Having said that, you'll certainly be OK without it for everything else.
Cheers,
I have query regarding connecting mysql to comand prompt.
I did:
open cmd prompt
telnet localhost com 3306
I RECEIVED REPLY as---
some instructions mentioning
telnet [-a][-e escape char][-f log file][-1 user][-t term][host [port]]
-a attempt automatic logon. same as -1 option except uses the currently logged on user's name.
-e Escape char to enter telnet client prompt.
and some more...
but is it right?? or i am lost???
kindly help.
do not telnet to your mysql database.
Instead use the mysql command, a UI like db visualizer (they have a pay version and a free version), or the free ui that comes with maria db (a drop in replacement for mysql).
more more info on the mysql command, try running mysql --help or find it in the mysql reference manual
Edit: more info added here.
Telnet is not a "command prompt", it is a communication protocol (check out telnet protocol on wikipedia) and a program (that uses the communication protocol to communicate). You can not connect to mySql with telnet because mySql does not use the telnet protocol for communication.
I have only accessed mySql for jdbc, so I'm not sure how to solve your problem. I know there is a c api interface for mySql as well. Sections "20 Connectors and APIs," and "15 Replication" in the mysql reference might be helpful.
I get an error when I execute the command below from a DOS window in Windows XP with SQL Server 2008. -S is the option to specify the server name.
error: Sqlcmd: '-S': unknown option.
sqlcmd –S localhost –d databasename -i C:\files\somefile.sql –E
It's working now using '.' as the server name when I typed the line manually.
What I did earlier was type the command in an editor, copied the ine and pasted into the command line. My guess is that an invisible control character got in there during the copy. I opened another dos window and typed a similar command using 'localhost' and it worked. I never used sqlcmd to connect to a server so I thought my syntax was wrong.
localhost, . & (local) should all work and if you use a non existent server name it will complain that it couldn't connect. It shouldn't say -S is not an option.
Is localhost the correct reference to use? Try sqlcmd -L to get the list of servers.
LocalHost is for IIS
(LOCAL) is for SQL Server. Or you can use a period