How to find the MAMP's MySQL location?
MAMP Version 4.1.1 (492)
On my MAMP, I started the Nginx Server and MySQL Server.
and in the Preferences, I can see MySQL's active version.
But how can I get its location? I want to create a database in this MySQL, and configure its configuration file.
I have two ways for find it:
Method 1: from the Document
MAMP 4 stores data in /Applications/MAMP/db/mysql56
Method 2:
you can use the ps command to find it.
$ ps -ef | grep mysql
501 2061 1 0 11:48上午 ?? 0:00.06 /bin/sh /Applications/MAMP/Library/bin/mysqld_safe --port=8889 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log
501 2406 2061 0 11:48上午 ?? 0:00.53 /Applications/MAMP/Library/bin/mysqld --basedir=/Applications/MAMP/Library --datadir=/Applications/MAMP/db/mysql56 --plugin-dir=/Applications/MAMP/Library/lib/plugin --log-error=/Applications/MAMP/logs/mysql_error_log.err --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --socket=/Applications/MAMP/tmp/mysql/mysql.sock --port=8889
501 3596 461 0 12:10下午 ttys000 0:00.00 grep mysql
Related
According to docs of PostgreSQL, turning jit_profiling_support to on, PostgreSQL generate the data to allow to perf.
https://www.postgresql.org/docs/12/runtime-config-developer.html
If LLVM has the required functionality, emit the data needed to allow perf to profile functions generated by JIT. This writes out files to $HOME/.debug/jit/;
Now I set jit_profiling_support to on and execute some queries.
testdb=# show jit_profiling_support;
jit_profiling_support
-----------------------
on
(1 row)
Certainly, it generates the file to $HOME/.debug/jit/.
/home/postgres/.debug/jit/llvm-IR-jit-20191216-a64065:
total 12
drwx------ 2 postgres postgres 4096 Dec 16 13:47 .
drwx------ 12 postgres postgres 4096 Dec 17 14:08 ..
-rw------- 1 postgres postgres 2030 Dec 16 13:47 jit-3880.dump
However, I can't this dump file. I tried to read with perf, but failed (as below).
$ perf report -v -i /home/postgres/.debug/jit/llvm-IR-jit-20191216-a64065/jit-3880.dump
magic/endian check failed
incompatible file format (rerun with -v to learn more)
How can I read this file?
You should be doing "perf inject" to get symbols in "perf report".
perf inject -j -i perf.data -o perf.jitted.data
perf report -i perf.jitted.data
This should work.
More details: PostgreSQL uses LLVM compiler suite for JIT. The suite generates code at runtime, also dumps symbols information in binary data file ending with *.dump under JITDUMPDIR directory. The perf tool consumes these symbols during inject step to display correct profiling info.
I am trying to hook up my Grails app to Postgresql. My versions:
Grails Version: 3.2.4
| Groovy Version: 2.4.7
| JVM Version: 1.8.0_60
Postgres installed through Homebrew version 9.6.1
Pouring postgresql-9.6.1.yosemite.bottle.tar.gz
added newest postgres jdbc driver in build.gradle
dependencies {
runtime 'org.postgresql:postgresql:9.4-1206-jdbc4'
}
In application.yml under development datasource I've added
driverClassName: org.postgresql.Driver
dialect: org.hibernate.dialect.PostgreSQLDialect
dbCreate: none
username: myUsername
url: jdbc:postgresql://localhost:5432/business
I have a domain class named Firm with properties that match the firm table in business database.
package bus.proto
class Firm {
int id
String firm_name
static constraints = {
}
}
Postgres query
business=# select * from firm;
id | firm_name
----+--------------
1 | example_firm
(1 row)
business=#
I am now confused as to how to figure out my configuration. I had rebooted my Mac and not had any instances of Postgresql running. I the ran
brew services start postgres
and then ran a
sudo lsof -i -n -P | grep TCP
to get
postgres 807 username 5u IPv6 0x3ba11f77231b4ebb 0t0 TCP [::1]:5432 (LISTEN)
postgres 807 username 6u IPv4 0x3ba11f772808980b 0t0 TCP 127.0.0.1:5432 (LISTEN)
When I hit the firm/index page I get the exception
ERROR: column this_.version does not exist Position: 30
thrown by the line
def firms = Firm.list()
which is located in the index() method in the FirmController.
I'm not sure how to pinpoint the problem after searching for the error message. Any help would be greatly appreciated!
I searched for answers related to my question but not found what I'm looking for.
I have server with Linux CentOS 6.7. I need to connect to MS SQL Server 2005 on Windows Small Business Server 2003. In CentOS I installed FreeTDS and I managed to connect to SQL Server from terminal using this command:
# TDSVER=7.0 tsql -H ServerIPAdress -p 1433 -U username -P password
As far as I know this command bypass settings in freetds.conf.
Now I need to connect from PHP script. I'm using PDO extension and I tried this DSN string:
$db = new PDO("dblib:version=7.0;host=ServerIPAdress;dbname=Database;","username","password");
This leads me to first error:
Could not find driver
Ok, I understand that - my PHP 5.3.3 installation doesn't have installed PDO driver dblib.
My question: How can I install pdo_dblib driver in CentOS? Many tutorials and answers suggest to install through this command:
yum install php5-sybase
But that package doesn't exist:
No package php-sybase available.
If I check tsql configuration with command
tsql -C
I get these output:
Version: freetds v0.95
freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 5.0
iODBC: no
unixodbc: yes
As I understand I need to configure FreeTDS:
./configure --enable-msdblib --with-pdo-dblib=/usr/local
But how can I configure FreeTDS after instalation? I tried to remove current version but I can't find way to do that. Also I tried to install another version but configuration doesn't change.
Any advice are appreciated.
When I run command # odbcinst -j I can see this output:
unixODBC 2.3.0
DRIVERS ...........: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLSETPOSIROW Size.: 8
Content of my freetds.conf:
# $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".
# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
tds version = 7.0
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
; timeout = 10
; connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512
# A typical Sybase server
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 7.0
# A typical Microsoft server
[MSServer]
host = 192.168.1.55
port = 1433
tds version = 7.0
odbcinst.ini:
[FreeTDS]
Description = FreeTDS v7.0
Driver = /usr/local/lib/libtdsodbc.so
UsageCount = 1
odbc.ini:
[MSSQL]
Driver = FreeTDS
Description = MSSQL Server Connection
TDS_Version = 7.0
Trace = No
Server = MSServer
Port = 1433
Database = MyDatabase
Username = DOMAIN\MyUsername
Password = MyPassword
I can make connection with isql command when I specify username and password:
# isql -v MSSQL "DOMAIN\MyUsername" MyPassword
But if I omit username and password isql generate error:
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed
I suspect that my username make problems because I have to use DOMAIN name followed by backslash before username when I connect to SQL Server 2005.
UPDATE:
I succesfully made connection in PHP and now I can run queries. I added this line on top of my script: putenv("FREETDSCONF=/usr/local/etc/freetds.conf")
Why is this necessary?
Problem description:
My system user is milosz, which is mapped to the PostgreSQL user project_great in pg_ident.conf. I am using peer authentication to connect to a PostgreSQL database over a unix domain socket. This connection method works when using psql, but fails to work when using py-postgresql using the same parameters from within a Python script.
Here I am successfully connecting to the database using psql:
$ psql -U project_great \
> -d project_great \
> -h /var/run/postgresql
psql (9.3.4)
Type "help" for help.
project_great=>
Here is database_test.py:
#!/usr/bin/env python3
import postgresql
params = {
'user': 'project_great',
'database': 'project_great',
'unix': '/var/run/postgresql',
}
connection = postgresql.open(**params)
Here I am attempting to connect to the database by running ./database_test.py:
$ ./database_test.py
Traceback (most recent call last):
File "./database_test.py", line 11, in <module>
sys.exit(main(sys.argv))
File "./database_test.py", line 13, in main
connection = postgresql.open(**params)
File "/home/milosz/devel/project_great/.virtualenv/lib/python3.3/site-packages/postgresql/__init__.py", line 94, in open
c.connect()
File "/home/milosz/devel/project_great/.virtualenv/lib/python3.3/site-packages/postgresql/driver/pq3.py", line 2422, in connect
self._establish()
File "/home/milosz/devel/project_great/.virtualenv/lib/python3.3/site-packages/postgresql/driver/pq3.py", line 2548, in _establish
self.typio.raise_client_error(could_not_connect, creator = self, cause = exc)
File "/home/milosz/devel/project_great/.virtualenv/lib/python3.3/site-packages/postgresql/driver/pq3.py", line 514, in raise_client_error
raise client_error
postgresql.exceptions.ClientCannotConnectError: could not establish connection to server
CODE: 08001
LOCATION: CLIENT
CONNECTION: [failed]
failures[0]:
socket'/var/run/postgresql'
Traceback (most recent call last):
File "/home/milosz/devel/project_great/.virtualenv/lib/python3.3/site-packages/postgresql/protocol/client3.py", line 136, in connect
self.socket = self.socket_factory(timeout = timeout)
File "/home/milosz/devel/project_great/.virtualenv/lib/python3.3/site-packages/postgresql/python/socket.py", line 64, in __call__
s.connect(self.socket_connect)
PermissionError: [Errno 13] Permission denied
The above exception was the direct cause of the following exception:
postgresql.exceptions.ConnectionRejectionError: Permission denied
CODE: 08004
LOCATION: CLIENT
CONNECTOR: [Unix] pq://project_great#[unix::var:run:postgresql]/project_great
category: None
DRIVER: postgresql.driver.pq3.Driver
Since the parameters to the two connections are ostensibly the same and my permissions on the socket and its containing directory are fairly open, I do not know what the issue is. Using TCP is not a solution; I want to use unix domain sockets. The py-postgresql documentation indicates that connecting using unix domain sockets should work.
Configuration:
pg_hba.conf:
# TYPE DATABASE USER ADDRESS METHOD OPTION
local all all peer map=default
pg_ident.conf:
# MAPNAME SYSTEM-USERNAME PG-USERNAME
default postgres postgres
default milosz project_great
postgresql.conf:
...
port = 5432
unix_socket_directories = '/var/run/postgresql'
...
Here are the permissions on my socket directory:
$ ll /var/run/postgresql/
total 8
drwxrwsr-x 2 postgres postgres 100 May 17 00:20 ./
drwxr-xr-x 31 root root 900 May 17 00:41 ../
-rw-r--r-- 1 postgres postgres 5 May 17 00:20 9.3-main.pid
srwxrwxrwx 1 postgres postgres 0 May 17 00:20 .s.PGSQL.5432=
-rw------- 1 postgres postgres 70 May 17 00:20 .s.PGSQL.5432.lock
The PostgreSQL user project_great has been granted all privileges on the database project_great and both the user and the database exist.
I do not have a ~/.pgpass.
Environment:
Ubuntu 13.10
Python 3.3
PostgreSQL 9.3
py-postgresql 1.1.0
Craig Ringer suggested to run both programs under strace to find out if there is a relevant difference in the system calls. I grepped for /var/run/postgresql and found that while psql ran connect like so:
connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/postgresql/.s.PGSQL.5432"}, 110) = 0
./database_test.py ran connect like so:
connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/postgresql"}, 21) = -1 EACCES (Permission denied)
wherein lay the issue.
While psql expects the path to the directory in which the unix domain socket is located, py-postgresql expects the full path to the socket. Therefore, the fix was to modify database_test.py to read like so:
#!/usr/bin/env python3
import postgresql
params = {
'user': 'project_great',
'database': 'project_great',
'unix': '/var/run/postgresql/.s.PGSQL.5432',
}
connection = postgresql.open(**params)
Honestly, I feel silly for not having tried the full path as an earlier debugging step!
mongosniff is for looking at what's sent to the MongoDB server, but on a Mac with OS X Snow Leopard, it says
error finding device: no suitable device found
this is when mongod is running fine. Is there something that can make it work?
Update: thanks. after running it as root, for some reason it is not reporting any activities when a mongo is running with different queries on this same machine. One time I had an error and it reported once and that was it... was it to report each activity usually?
Have you tried running it as root? I get that error when I don't have permission to monitor network traffic.
Edit in response to your update:
You have to specify the network interface to sniff. Run ifconfig to see what your local network name is and then use:
sudo mongosniff --source NET lo
Running as root works for me:
bobk-mbp:~ bobk$ sudo mongosniff --source NET lo0
sniffing... 27017
10.78.4.213:14303 -->> 10.78.4.213:27017 admin.$cmd 58 bytes id:2447 9287
query: { ismaster: 1 } ntoreturn: -1 ntoskip: 0
10.78.4.213:27017 <<-- 10.78.4.213:14303 87 bytes id:2789 10121 - 9287
reply n:1 cursorId: 0
{ ismaster: true, maxBsonObjectSize: 16777216, ok: 1.0 }
...also, ifconfig shows that the LOOPBACK is on lo0 on my system.