how to execute SQL statements in command prompt (CMD) [closed] - sql

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
The community reviewed whether to reopen this question 10 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
how to execute SQL statements in command prompt (CMD),
I'm using SQL Server 2012 in windows 8 OS.
I have tried sqlplus and sqlcmd, both are giving error "

You are looking for the sqlcmd utility lets you enter Transact-SQL statements, system procedures, and script files at the command prompt
sqlcmd -U myLogin -P myPassword -S MyServerName -d MyDatabaseName
-Q "query"
Refer this
Edit: The OP said The sqlcmd.exe file is available in the installation path C:\Program Files\Microsoft SQL Server\110\Tools\Binn
You are executing with C:\Users> make the path to C:\Program Files\Microsoft SQL Server\110\Tools\Binn and execute sqlcmd or add the sqlcmd path (C:\Program Files\Microsoft SQL Server\110\Tools\Binn) to system PATH

Related

Windows 11 Ubuntu WSL2 - Autostarting services with /etc/wsl.conf doesn't work [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 12 months ago.
Improve this question
I'm attempting to start docker and postgresql automatically with my ubuntu wsl2 instance. I read about the /etc/wsl.conf configuration file and it only starts one service, not two. For example if I have:
[boot]
command = service docker start
and restart wsl.. I get the following:
mryan ~ $service docker status
* Docker is not running
mryan ~ $service postgresql status
12/main (port 5432): online
Again, if I remove the last line from etc/wsl.conf and restart wsl. Docker starts just fine. I've also tried quotes around the commands as in command="service docker start" but it didn't make a difference. Is there some format error I'm making here? Any help would be appreciated. I can get around this by manually starting services but it would be nice to make things work properly!
Try combining the commands into a single line maybe, with &&.
One still can start it on demand, eg. with .bashrc or .zshrc:
RUNNING=`ps aux | grep dockerd | grep -v grep`
if [ -z "$RUNNING" ]; then
sudo dockerd > /dev/null 2>&1 &
disown
fi
This may require group docker:
sudo usermod -a -G docker $USER

Completely remove MariaDB 10.01 in Ubuntu 18.04 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
The community reviewed whether to reopen this question 14 days ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I am having a problem while trying to completely purge Maria DB and install it again.
This is what I do to remove it :
2073 sudo apt-get remove --purge maria*
2074 rm -f /var/log/mariadb
2075 rm -f /var/log/mariadb/mariadb.log
2076 rm -rf /var/lib/mysql
2077 rm -rf /usr/lib64/mysql
2078 rm -rf /usr/share/mysql
And then I attempt to reinstall as :
sudo apt install mariadb-server
mysql_secure_installation
But the problem is once I do it I am being prompted for the root password, which should not be set as I have supposedly purged everything.
Output from mysql_secure_installation :
[~]#Ubuntu1804 #> mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
Enter current password for root (enter for none):
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
Enter current password for root (enter for none):
Aborting!
If I leave it blank it fails, but If I try with the right password it fails as well.
How can I remove everything related to MariaDB from the server?
Just run this command
sudo apt-get purge mariadb-*
So in my case, I ended up going to /etc and removing the folder called mysql. It looks obvious but I thought that it would be done automatically when removing? the app via the package manager.

ssh tmux: execute long running command using ssh programmatically [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I need to programmatically execute long running script on a remote server. I tried to use ssh with screen or tmux and so far I could not make it work.
With tmux I managed to make it work when typing the ssh command from my local machine terminal:
ssh <server_name> -t -t tmux new -s my_session \; set-buffer "bash my_script.sh" \; paste-buffer \; send-keys C-m \; detach
But if I run this programmatically I get this error:
open terminal failed: missing or unsuitable terminal: unknown
Connection to <server_name> closed
Use the -d flag to new-session to start tmux detached. So:
ssh <server_name> tmux new -ds my_session \; send-keys "bash my_script.sh" C-m

Unable to run sshpass command in centOS [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Have work on CentOS release 6.3 (Final) system. And try to ssh another machine using sshpass utility like
sshpass -p 'password' ssh user#host
But it give me error like
sshpass: Failed to run command: No such file or directory
So from error i think that sshpass may be not install so have try to install it by yum install sshpass and get following log
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.leapswitch.com
* epel: epel.mirror.net.in
* extras: mirror.leapswitch.com
* nux-libreoffice.org-rpms: mirror.li.nux.ro
* updates: mirror.leapswitch.com
Setting up Install Process
Package sshpass-1.05-1.el6.i686 already installed and latest version
Nothing to do
from above it seems sshpass is already installed.So why it not working?
Check if your shell knows the locations of sshpass
which sshpass
If it doesnt give any output use find command to find the location of the executable:
find / -name sshpass
If you find the path, you can either use the full path of the executable:
/path/to/sshnpass
Or add the path to the PATH environmental variable, so that your shell can locate it:
export PATH=$PATH:/path/to/
Or the issue might be completely different. sshpass might not be able to find some other dependency. "ssh" client might not be installed. Or your syntax might be wrong:

Creating TAR file reading standard output [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to get into tar file the stdout generated from Mysqldump:
mdm#deb606:~$ mysqldump --opt test1 -u root -ppassword | tar -czf example.tar.gz
doesn't work.
At the moment I've temporary solved using:
mdm#deb606:~$ mysqldump --opt test1 -u root -ppassword | gzip -f > example.gz
Is it possible do the the same using also tar or bzip2?
I don't know that it's possible to pipe directly into tar (in general, that doesn't make a lot of sense), however the bzip2 command will accept - to mean to read from stdin, i.e.:
mdm#deb606:~$ mysqldump --opt test1 -u root -ppassword | bzip2 - > example.bz2