I have installed two version of postgreSQL on my Windows 7 dev box. Ver. 9.1 (32-bit) and 9.2 (64-bit). During installation I assigned ver. 9.1 port 5432 and ver 9.2 port 5433. However, whenever I run basic commands like createdb.exe from the 9.2\bin directory, the command runs against the wrong port. Regardless of what commands I run, they always default to the port of the first install (5432). The install directories and data directories are in different locations.
If you don't specify a port, the Postgres tools (e.g. psql) default to 5432. Use the -p switch to change the port that the tool should use, e.g.
psql -p 5433 mydb myuser
Or for the createdb command:
createdb -p 5433 the_new_db
Please read the respective chapters in the manual for details.
If you don't want to specify the port number each time, you can set an environment variable that is picked up by the Postgres tools. This is also explained in the manual: http://www.postgresql.org/docs/current/static/libpq-envars.html
Related
I am trying to connect to a Microsoft SQL Server database from R studio.
I installed the unixODBC driver manager using homebrew:
brew install unixodbc
I then tried to install the freetds driver as recommended on https://db.rstudio.com/best-practices/drivers/
# SQL Server ODBC Drivers (Free TDS)
brew install freetds --with-unixodbc
I received the error:
Error: invalid option: --with-unixodbc
I found a source saying the option is no longer available because it is default now. Thus, I ran:
brew install freetds
In R Studio (and R) I then attempted to list the installed driver, but it was not found:
> odbc::odbcListDrivers()
[1] name attribute value
<0 rows> (or 0-length row.names)
Next I tried to install the Microsoft ODBC driver for SQL Server (macOS) according to https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15 and as recommended on https://db.rstudio.com/databases/microsoft-sql-server/
I ran:
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
HOMEBREW_NO_ENV_FILTERING=1 ACCEPT_EULA=Y brew install msodbcsql17 mssql-tools
To check that this driver was registered in an odbcinst.ini file I first ran:
odbcinst -j
with result:
unixODBC 2.3.9
DRIVERS............: /opt/homebrew/etc/odbcinst.ini
SYSTEM DATA SOURCES: /opt/homebrew/etc/odbc.ini
FILE DATA SOURCES..: /opt/homebrew/etc/ODBCDataSources
USER DATA SOURCES..: /Users/Gina/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
The driver was already registered in /opt/homebrew/etc/odbcinst.ini
view /opt/homebrew/etc/odbcinst.ini
file contents (note the freetds driver does not appear to be present):
[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/homebrew/lib/libmsodbcsql.17.dylib
UsageCount=1
In Rstudio, I tried again to list the drivers and none were found:
> odbc::odbcListDrivers()
[1] name attribute value
<0 rows> (or 0-length row.names)
I have tried many more things, including:
copying the contents of /opt/homebrew/etc/odbcinst.ini to the user level file /Users/Gina/.odbcinst.ini
editing the /opt/homebrew/etc/odbc.ini file (which was previously empty) to include connection details (though I was planning to just specify these in the DBI::dbConnect command). New redacted file contents:
[ODBC Driver 17 for SQL Server]
Driver = ODBC Driver 17 for SQL Server
Servername = servername.net
Database = databasename
UserName = rstudioapi::askForPassword("Database user")
Password = rstudioapi::askForPassword("Database password")
Port = 1433
copying the contents of the /opt/homebrew/etc/odbc.ini to the user level file /Gina/.odbc.ini
setting an environmental variable:
export ODBCSYSINI=/opt/homebrew/etc
Note that when I run:
odbcinst -q -s
The driver is found:
[ODBC Driver 17 for SQL Server]
Thus, it appears that odbc::odbcListDrivers() should be able to find the driver. Any thoughts or suggestions would be very much appreciated! Thank you!
EDIT:
I also tried using the New Connection button and interestingly, my driver is listed there!
New Connection Window
However, when I click on it and click Test, I get an error:
Error: nanodbc/nanodbc.cpp:1021: 00000: [unixODBC][Driver Manager]Data source name not found and no default driver specified
Driver Connection Window with Error
I get the same error when I try:
isql -v ODBC Driver 17 for SQL Server myusername mypassword
[IM002][unixODBC][Driver Manager]Data source name not found and no
default driver specified
EDIT 2:
I changed the Data Source Name (top line in odbc.ini file) to "SQLSever" and changed the Servername argument to Server (I did this in both the system level file and the user level file). Now when I run the below command it tries to connect (though hits a new error).
isql -v SQLServer myusername mypassword
[08001][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]SSL
Provider: [OpenSSL library could not be loaded, make sure OpenSSL
1.0 or 1.1 is installed]
[08001][unixODBC][Microsoft][ODBC Driver 17 for SQL Server]Client
unable to establish connection
[ISQL]ERROR: Could not SQLConnect
However, unfortunately, I still can not connect in R. I get the same errors as before.
Note that it appears that the isql command uses the system level files and RStudio uses the user level files. The files are identical in both places.
I read in a post on a similar issue that the M1 Macs have this problem but non-M1 Macs do not. Thus, I tried repeating the whole process on an older Macbook Pro and did not encounter the problem! odbc::odbcListDrivers() immediately listed the driver after installing the Microsoft ODBC driver for SQL Server (macOS). I did not need to edit or create any files.
With M1 Mac I was able to connect to SQL Server through terminal by changing the openssl folder to an older version. The driver installs openssl#3 (opt/homebrew/opt/openssl#3) but you actually need to use openssl#1.1 instead.
Here are the steps i followed in terminal:
brew install openssl#1.1
rm /opt/homebrew/opt/openssl
ln -s /opt/homebrew/Cellar/openssl#1.1/1.1.1l_1 /opt/homebrew/opt/openssl
This will create a symlink "openssl" and point it to the correct file (1.1.1l_1) inside the opt/homebrew/Cellar/openssl#1.1 folder.
Before creating the symlink verify the file name 1.1.1l_1 has not changed with a newer version in opt/homebrew/Cellar/openssl#1.1/1.1.1l_1
This solution worked for me:
Create two symlinks:
sudo mkdir -p /usr/local/etc
sudo ln -s /opt/homebrew/etc/odbc.ini /usr/local/etc/odbc.ini
sudo ln -s /opt/homebrew/etc/odbcinst.ini /usr/local/etc/odbcinst.ini
First of all, thanks a lot for your time!
I upgraded MariaDB on Ubuntu 18.04 and restarted: sudo systemctl restart mysql.server several times.
When I run command mysql -V it shows:
mysql Ver 15.1 Distrib 10.3.14-MariaDB, for debian-linux-gnu (x86_64)
using readline 5.2
When I run query SELECT VERSION(); it shows:
10.1.38-MariaDB-0ubuntu0.18.04.1
Any help would be appreciated.
The mysql executable you have installed has a different version than the server it connects to.
Make sure you are connecting to the correct server. Sometimes the configuration defaults file points you automatically to a remote server.
Check where the mysql executable is found from using command -v mysql or which mysql. Most of the time the binary is located in /usr/bin/mysql so you might try invoking that directly to see if that helps.
user_1 (master *) 1_EchoServer $ python -m http.server 8000
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
127.0.0.1 - - [30/Sep/2017 18:57:11] "GET / HTTP/1.1" 200 -
Set up a simple server. I want to connect to it with ncat to learn HTTP.
I install ncat (pip install nmap):
user_1 Documents $ pip install nmap
Requirement already satisfied: nmap in c:\python36\lib\site-packages
Then, when I try and connect, cmd not found. It was working earlier. Not sure how I broke it.
user_1 Documents $ pip install nmap
Requirement already satisfied: nmap in c:\python36\lib\site-packages
user_1 Documents $ ncat -l 9999
bash: ncat: command not found
I am using git bash on windows, and I have set up python36 on c drive and changed env variables and path accordingly.
I have been in this problem today and I solved it.
the Nmap command must be in the $PATH environment variable for the discovery service account. To do this on windows do the following steps
Click Start > Control Panel > System
Click the Advanced tab, and select Environment Variables.
Edit the Path system variable and add the directory where Nmap is installed.
Restart the computer.
If you do this task, Nmap should be available to services on the computer and the command will be found in the terminal
The Python "nmap" package which you installed with pip install nmap is only an output parsing library. It does not include the Nmap binary. The "nmap" package available in the Windows Subsystem for Linux (a.k.a. Bash on Windows, a.k.a. Ubuntu on Windows) does not currently work properly and is unsupported.
The only place to get Nmap (and Ncat) in ready-to-use format (binary executable) on Windows is directly from nmap.org.
This is the third time I'm setting up Postgres on a new machine (OS X 10.9 this time), and the third time I'm having problems with the connection.
Basically, I'm at the point where I've created a database cluster and can start postgres using:
postgres -D /usr/local/pgsql/data
But I want it to run in the background as a launch daemon, so I
sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql91-server.plist
It seems like the daemon is launched successfully. But when I type psql I get the same old error message I've been dealing with every single time I try to set up Postgres:
psql: could not connect to server: No such file or directory. Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Any ideas on what might be causing this?
The psql you're running is the old version bundled by Apple in Mac OS X and added to the default PATH. Use the one from Homebrew, by fixing your path or entering the path specifically.
Alternately, explicitly connect to the server by overriding the default socket directory:
psql -h /tmp
See also:
this superuser answer
How to modify PATH for Homebrew?
Update:
In this case it looks like the server is genuinely not starting. Check the permissions on the data directory (apparently /usr/local/pgsql/data) and check the Console.app logs for relevant messages from launchd.
Update:
You must fix the permissions so the postgres user (or postgres_, depending on how you installed) has ownership. Check the launchd config file to see what user it runs as, and sudo chown -R postgres /usr/local/pgsql/data to change ownership. Replace postgres with postgres_ if that's what your launchd config says
I am trying to run a simple MPI program using MPICH over a cluster of two machines. However, one is running Fedora 17 and the other is running Debian Squeeze - not necessarily a problem, but the issue is that the two distros put their mpi execs in different directories:
When I run the following from host1:
mpiexec -hosts host2 -np 1 -wdir /home/chris/src/mpi/ ./mpitest
it fails with the following error
bash: /usr/lib/mpich2/bin/hydra_pmi_proxy: No such file or directory
This seems to be because hydra_pmi_proxy is installed in /usr/lib/mpich2/bin on the Fedora machine but in /usr/bin on the Debian machine. I assume that when I spawn the process from host1 via ssh, it expects to find hydra_pmi_proxy in the same place on host2.
The program runs ok on both machines if I just run it locally on that node - I only get a problem when trying to run it on both.
I have searched the MPICH documentation for a way to override to remote path to hydra_pmi_proxy, but to no avail.
Can I do this somehow? I thought one of the advantages of MPICH was that it can easily handle hetrogeneous hosts....
Any insights would be most appreciated!
I managed to solve this problem not installing mpich hydra and the terminal (eg apt-get install MPICH2 or hydra). But instead I downloaded the source code: http://www.mpich.org/downloads/ (being the stable version).
Then I ran the following command on the machines Master and slave: export PATH = / home / you / mpich: $ PATH (On my computer I installed on my mpich directory).
Just solved this problem!
Thanks!
This can be solved by installing MPICH via its source code and mount the installation directory in the node in the same directory as the directory on server. then use export PATH = /home/you/mpich-installation-directory/bin: $PATH only on server.
This problem can be solved in NFS configuration with: exportfs -var (in master machine).
You have your /mirror directory, but it is necessary to add the directory /usr in /etc/exports:
/usr *(rw,sync,no_subtree_check)
In the client machine, edit /etc/fstab and add:
master-ip/usr /usr nfs defaults 0 0
Save and run the command mount -a.
After run df -h to see the mounted directory from master in slave/client.