I installed MariaDB on my Mac Monterey using Homebrew. But I cannot login MariaDB after I dropped root users and other local users even I reinstalled it.
So I looked for solutions on google and luckily enough I can login MariaDB using mysqld_safe --skip-grant-tables --skip-networking from this link enter link description here. I checked the databases and tables to see any abnormalities and I finally find that there is no table in mysql database.
Here's the MariaDB information.
# moonwatcher # MoonWatcherdeMacBook-Air in /usr/local/etc [14:52:33]
$ brew info mariadb
mariadb: stable 10.8.3 (bottled)
Drop-in replacement for MySQL
https://mariadb.org/
Conflicts with:
mariadb-connector-c (because both install `mariadb_config`)
mysql (because mariadb, mysql, and percona install the same binaries)
mytop (because both install `mytop` binaries)
percona-server (because mariadb, mysql, and percona install the same binaries)
/usr/local/Cellar/mariadb/10.8.3_1 (920 files, 187.5MB) *
Poured from bottle on 2022-08-14 at 13:40:39
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/mariadb.rb
License: GPL-2.0-only
==> Dependencies
Build: bison ✘, cmake ✘, fmt ✘, pkg-config ✔
Required: groonga ✔, openssl#1.1 ✔, pcre2 ✔, zstd ✔
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
MySQL is configured to only allow connections from localhost by default
To restart mariadb after an upgrade:
brew services restart mariadb
Or, if you don't want/need a background service you can just run:
/usr/local/opt/mariadb/bin/mysqld_safe --datadir=/usr/local/var/mysql
==> Analytics
install: 12,338 (30 days), 43,510 (90 days), 161,252 (365 days)
install-on-request: 12,321 (30 days), 43,452 (90 days), 160,988 (365 days)
build-error: 29 (30 days)
(base)
Associated my.cnf files
# moonwatcher # MoonWatcherdeMacBook-Air in /usr/local/etc [14:53:42]
$ ls
bash_completion.d gitconfig init.d mecabrc my.cnf.d my.cnf.default.default wgetrc
ca-certificates groonga logrotate.d my.cnf my.cnf.default openssl#1.1
(base)
# moonwatcher # MoonWatcherdeMacBook-Air in /usr/local/etc [14:53:43]
$ cat my.cnf
#
# This group is read both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include *.cnf from the config directory
#
!includedir /usr/local/etc/my.cnf.d
(base)
# moonwatcher # MoonWatcherdeMacBook-Air in /usr/local/etc [14:53:52]
$ cat my.cnf.default
# Default Homebrew MySQL server config
[mysqld]
#skip-grant-tables
# Only allow connections from localhost
bind-address = 127.0.0.1
(base)
# moonwatcher # MoonWatcherdeMacBook-Air in /usr/local/etc [14:53:57]
$ cat my.cnf.default.default
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
(base)
No tables in mysql database
# moonwatcher # MoonWatcherdeMacBook-Air in ~ [14:54:23]
$ mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 41
Server version: 10.8.3-MariaDB Homebrew
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| homebrew |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.002 sec)
MariaDB [(none)]> use mysql;
Database changed
MariaDB [mysql]> show tables;
Empty set (0.001 sec)
MariaDB [mysql]>
Related
I was trying to downgrade elasticsearch from 6.8.4 to 5.6 on my Mac machine. But somehow I mess with the existing installation of 6.8.4 and now neither I am able to fix the current installed version nor I am able to install 5.6
Details:
I had 6.8.4 installed correctly on my system and I was successfully able to hit http://localhost:9200/ port and see the version info and every other details. But due to a dependency, I had to downgrade the version to 5.6
I followed this guide https://gist.github.com/govindpatel/0660b33a343b807664972b53c3b12ca0 and messed with the installation of 6.8.4 by removing plist entry and other details. Now when I try to start elasticsearch service by typing $ elasticsearch I get: -bash: elasticsearch: command not found and $ brew service restart elasticsearch gives me Error: Unknown command: service
However, I can still see 6.8.4 when I fire this command:
$ brew info elasticsearch
elasticsearch: stable 6.8.4, HEAD
Distributed search & analytics engine
https://www.elastic.co/products/elasticsearch
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/elasticsearch.rb
==> Requirements
Required: java = 1.8 ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
Data: /usr/local/var/lib/elasticsearch/
Logs: /usr/local/var/log/elasticsearch/elasticsearch_Puneet.log
Plugins: /usr/local/var/elasticsearch/plugins/
Config: /usr/local/etc/elasticsearch/
To have launchd start elasticsearch now and restart at login:
brew services start elasticsearch
Or, if you don't want/need a background service you can just run:
elasticsearch
==> Analytics
install: 8,690 (30 days), 23,748 (90 days), 122,267 (365 days)
install_on_request: 8,233 (30 days), 22,565 (90 days), 114,157 (365 days)
build_error: 0 (30 days)
I've even tried installing 5.6 (via Homebrew) - brew install elasticsearch#5.6 and set the PATH at first place in ~/.bash_profile but no luck! :(
Please help and advise on:
How can I fix the existing 6.8.4 version, and
How can I downgrade it systematically (because existing conf, data lies under /usr/local folder)
Current details: to see if elasticsearch is running: $ launchctl list | grep elasticsearch, I am getting: - 1 homebrew.mxcl.elasticsearch#5.6 and I do not have this currently installed (o/p attached) - $ brew uninstall elasticsearch#5.6 ~> Error: No such keg: /usr/local/Cellar/elasticsearch#5.6
[UPDATE-1]
After posting this, I tried running the ES installation command again: brew install elasticsearch
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
No changes to formulae.
==> Downloading
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-6.8.4.tar.gz
Already downloaded: /Library/Caches/Homebrew/downloads/elasticsearch-oss-6.8.4.tar.gz
==> Caveats
Data: /usr/local/var/lib/elasticsearch/
Logs: /usr/local/var/log/elasticsearch/elasticsearch_Puneet.log
Plugins: /usr/local/var/elasticsearch/plugins/
Config: /usr/local/etc/elasticsearch/
To have launchd start elasticsearch now and restart at login:
brew services start elasticsearch
Or, if you don't want/need a background service you can just run:
elasticsearch
==> Summary
🍺 /usr/local/Cellar/elasticsearch/6.8.4: 133 files, 103.2MB, built in 6 seconds
and then started the service $ brew services start elasticsearch ~> ==> Successfully startedelasticsearch(label: homebrew.mxcl.elasticsearch). Now when I tried accessing the port: http://localhost:9200 -- it's working (install from 0 fixed this though!)
{
"name" : "DwQRyf7",
"cluster_name" : "elasticsearch_Puneet",
"cluster_uuid" : "hLAu9onQSiuQHOpm_e9IKw",
"version" : {
"number" : "6.8.4",
"build_flavor" : "oss",
"build_type" : "tar",
"build_hash" : "bca0c8d",
"build_date" : "2019-10-16T06:19:49.319352Z",
"build_snapshot" : false,
"lucene_version" : "7.7.2",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
The only question remains now is, how can I downgrade it systematically?
[UPDATE-2]
Now that I have 6.8.4 with me, I've checked for other versions with: brew search elasticsearch and got 5.6. Then I installed 5.6 with brew install elasticsearch#5.6
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
No changes to formulae.
==> Downloading https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.16.tar.gz
Already downloaded: /Library/Caches/Homebrew/downloads/3d7cc028f605699065bd403b0a2383db8d7413c570df57e26fc87a735126c96c--elasticsearch-5.6.16.tar.gz
==> Caveats
Data: /usr/local/var/elasticsearch/elasticsearch_Puneet/
Logs: /usr/local/var/log/elasticsearch/elasticsearch_Puneet.log
Plugins: /usr/local/opt/elasticsearch#5.6/libexec/plugins/
Config: /usr/local/etc/elasticsearch/
plugin script: /usr/local/opt/elasticsearch#5.6/libexec/bin/elasticsearch-plugin
elasticsearch#5.6 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have elasticsearch#5.6 first in your PATH run:
echo 'export PATH="/usr/local/opt/elasticsearch#5.6/bin:$PATH"' >> ~/.bash_profile
To have launchd start elasticsearch#5.6 now and restart at login:
brew services start elasticsearch#5.6
Or, if you don't want/need a background service you can just run:
/usr/local/opt/elasticsearch#5.6/bin/elasticsearch
==> Summary
🍺 /usr/local/Cellar/elasticsearch#5.6/5.6.16: 106 files, 36.0MB, built in 6 seconds
Then I added 5.6 to $PATH. Now, when I am trying to switch elasticsearch version using brew switch elasticsearch 5.6 I am getting:
Error: elasticsearch does not have a version "5.6" in the Cellar.
elasticsearch installed versions: 6.8.4
Any idea what I am missing here?
Looks like I found the solution after troubleshooting for a while.
In order to maintain multiple versions of elasticsearch on your development machine, here's what you need to do:
Let's say I have 6.8.4 installed and I want another version as well. In order to maintain both, first check what all versions your system (mac) has by typing: brew search elasticsearch and my system have 3 versions supported for ES:
elasticsearch - Latest and stable (already installed)
elasticsearch#2.4
elasticsearch#5.6
In order to have 2.4, here's what you'll have to do:
$ brew install elasticsearch#2.4
# After installation type:
$ brew services stop elasticsearch
# above command will stop elasticsearch (lastest stable) service
# add 2.4 to $PATH
$ echo 'export PATH="/usr/local/opt/elasticsearch#2.4/bin:$PATH"' >> ~/.bash_profile
# start the service of 2.4
$ brew services start elasticsearch#2.4
# check for the service/installation
$ launchctl list | grep elasticsearch
# above command should show you a port
Now you can hit http://localhost:9200 in browser and it should show you 2.4
To switch back to latest stable version:
$ brew services stop elasticsearch
# remove entry from $PATH variable
$ brew services start elasticsearch
It seems to me that brew switch elasticsearch [VERSION] does not work
Seems brew fails to uninstall protobuf completely:
brew uninstall protobuf --force
brew uninstall protobuf#3.1 --force
brew info protobuf
protobuf: stable 3.6.1 (bottled), HEAD
Protocol buffers (Google's data interchange format)
https://github.com/protocolbuffers/protobuf/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/protobuf.rb
==> Dependencies
Build: autoconf ✘, automake ✘, libtool ✔
Recommended: python#2 ✔
Optional: python ✘
==> Options
--with-python
Build with python support
--without-python#2
Build without python2 support
--HEAD
Install HEAD version
==> Caveats
Editor support and examples have been installed to:
/usr/local/Cellar/protobuf/3.6.1/share/doc/protobuf
==> Analytics
install: 20,550 (30 days), 75,916 (90 days), 307,704 (365 days)
install_on_request: 10,362 (30 days), 36,197 (90 days), 141,839 (365 days)
build_error: 0 (30 days)
brew uninstall protobuf
Error: No such keg: /usr/local/Cellar/protobuf
protoc
-bash: /usr/local/opt/protobuf#3.1/bin/protoc: No such file or directory
What is the proper way to uninstall it completely?
It’s not Homebrew’s fault: it’s Bash’.
When you type protoc, Bash searches the executable in your PATH. In your case, it’s /usr/local/opt/protobuf#3.1/bin/protoc. However, it only does that the first time: it caches its findings for the session.
You uninstalled protobuf and so Homebrew removed the /usr/local/opt/protobuf#3.1/bin/protoc file; but you haven’t cleared Bash’ cache, so it still thinks this file exists.
The solution is to either start a new shell session or force Bash to clear its cache with hash -r.
Illustration:
$ touch /tmp/hi
$ chmod u+x /tmp/hi
$ export PATH="/tmp:$PATH"
$ which hi
/tmp/hi
$ hi # <-- executes /tmp/hi and cache hi=/tmp/hi
$ rm /tmp/hi
$ hi # <-- still executes /tmp/hi because of the cache
bash: /tmp/hi: No such file or directory
$ hash -r # clear the cache
$ hi
hi: command not found
I am starting to use PostgreSQL on my Mac but I am stumped as to how I should go about it
I tried out instructions given in the below sites :
http://exponential.io/blog/2015/02/21/install-postgresql-on-mac-os-x-via-brew/
https://www.codementor.io/devops/tutorial/getting-started-postgresql-server-mac-osx
https://gist.github.com/sgnl/609557ebacd3378f3b72
but to little avail.
Here is my terminal log:-
Pavan7Vasans-MacBook-Pro:~ pavan7vasan$ brew install postgresql
Updating Homebrew...
Warning: postgresql 9.6.5 is already installed
Pavan7Vasans-MacBook-Pro:~ pavan7vasan$ postgres --version
postgres (PostgreSQL) 9.3.5
Pavan7Vasans-MacBook-Pro:~ pavan7vasan$ psql 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"?
Pavan7Vasans-MacBook-Pro:~ pavan7vasan$ which postgresql
Pavan7Vasans-MacBook-Pro:~ pavan7vasan$ which postgres
/usr/local/php5/bin/postgres
Pavan7Vasans-MacBook-Pro:~ pavan7vasan$ postgres -D /usr/local/var/postgres
LOG: unrecognized configuration parameter "dynamic_shared_memory_type" in file "/usr/local/var/postgres/postgresql.conf" line 126
FATAL: configuration file "/usr/local/var/postgres/postgresql.conf" contains errors
Pavan7Vasans-MacBook-Pro:~ pavan7vasan$ postgres -D
/usr/local/php5/bin/postgres
postgres cannot access the server configuration file
"/usr/local/php5/bin/postgres/postgresql.conf": Not a directory
Pavan7Vasans-MacBook-Pro:~ pavan7vasan$ pg_ctl -D /usr/local/var/postgres start && brew services start postgresql
server starting
LOG: unrecognized configuration parameter "dynamic_shared_memory_type" in file "/usr/local/var/postgres/postgresql.conf" line 126
FATAL: configuration file "/usr/local/var/postgres/postgresql.conf" contains errors
Service `postgresql` already started, use `brew services restart
postgresql` to restart.
Pavan7Vasans-MacBook-Pro:~ pavan7vasan$ brew services restart postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
Pavan7Vasans-MacBook-Pro:~ pavan7vasan$ postgres -V
postgres (PostgreSQL) 9.3.5
Pavan7Vasans-MacBook-Pro:~ pavan7vasan$
what has me in a fix is that despite the latest version of PostgreSQL being installed through homebrew, the current version is 9.3.5
Is this because of an older version of PostgreSQL present as shown through the which postgres command is conflicting?
Are all the above errors due to the older version still being the current version?
If possible, how do I change the version to the latest version?
Please do tell me what is to be done
I'm using Mac OS X 10.8.5 and trying to install postgreSQL using homebrew. I've fixed several errors and warnings which have occurred when I ran brew info postgresql. However, I don't know how to fix the rest of the problems.
$brew info postgresql
postgresql: stable 9.3.2 (bottled)
http://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.3.2 (2924 files, 40M) *
Poured from bottle
From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/postgresql.rb
==> Dependencies
Required: readline ✔
Recommended: ossp-uuid ✔
==> Options
--32-bit
Build 32-bit only
--enable-dtrace
Build with DTrace support
--no-perl
Build without Perl support
--no-tcl
Build without Tcl support
--without-ossp-uuid
Build without ossp-uuid support
--without-python
Build without python support
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/Homebrew/homebrew/issues/issue/2510
To migrate existing data from a previous major version (pre-9.3) of PostgreSQL, see:
http://www.postgresql.org/docs/9.3/static/upgrading.html
When installing the postgres gem, including ARCHFLAGS is recommended:
ARCHFLAGS="-arch x86_64" gem install pg
To install gems without sudo, see the Homebrew wiki.
To have launchd start postgresql at login:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
postgres -D /usr/local/var/postgres
When I run server, I get:
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `initialize': could not connect to server: No such file or directory (PG::ConnectionBad)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
I've uninstalled postgresql and reinstalled but seems like I wasn't able to remove the postgresql 8.x version.
I've read several different posts to install and run postgreSQL properly and tried what they've suggested but nothing seems to be working for me.
Installing PostgreSQL in Mac OS X El Capitan using homebrew
First check the 'owner' of the folder '/usr/local' by using this command:
$ ls -la '/usr'
If the owner of the file is 'root', run this command to change the owner to your currently logged user:
$ sudo chown -R `whoami` /usr/local
Install PostgreSQL using homebrew:
$ brew update
$ brew doctor
$ brew install postgresql#15
and that's it!
Uninstall PostgreSQL using homebrew:
$ brew uninstall postgres
then remove this folder: '/usr/local/var/postgres' and then change back the owner of your local
local folder to:
$ sudo chown -R root /usr/local
How to:
List brew services: $ brew services list
Run brew services: $ brew services start <service_name>
ex: $ brew services start postgresql
Stop brew serices: $ brew services stop <service_name>
Logging in to PostgreSQL for the first time:
1.) Run the postgres: $ brew services star postgresql
2.) Create a db using your username: $ createdb `whoami`
3.) Login to postgres: $ psql
To quit psql, just type: \q
4.) Create database (using terminal):
$ createdb <db_name>
psql tutorial:
http://blog.trackets.com/2013/08/19/postgresql-basics-by-example.html
http://exponential.io/blog/2015/02/21/install-postgresql-on-mac-os-x-via-brew/
Optional, installing pgAdmin:
1.) Download pdadmin: https://www.pgadmin.org/download/macosx.php
2.) Press ctrl+click then open to run the dmg file then drag it to your
Application folder. ctrl+click the pdadmin to run it so that it won't
ask for that annoying question again.
Login in to pgAdmin:
Note: Use your username and password when you installed your postgres for first login
then create a new user with privileges later or just change your password from
'File -> Change Password...'
Your Ruby code is apparently linked against the system version of PostgreSQL, which looks for a socket in /var/pgsql_socket. The Homebrew version would look in /tmp. (At this point, make sure that a file like /tmp/.s.PGSQL.5432 exists.) To work around this, you can tell your code to connect to the Homebrew version by specifying /tmp with the "host" option, however your code spells that.
In the future, make sure your Ruby gems are linked against the Homebrew version. Perhaps just uninstalling and reinstalling with the right paths set would do it.
Locally, it appears that I have Postgresql 9.2.4 installed. I am guessing based off the last error message I received that I do not have the latest version:
pg_dump: server version: 9.3.1; pg_dump version: 9.2.4
pg_dump: aborting because of server version mismatch
On other posts here, what was told to do was to add the following the the .profile and then run the command:
export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
. ~/.profile
which did not work.
2 weeks ago, I installed Postgresql with the simple command:
brew install postgresql
and that gave me the version I currently have. It appears as I don't have the latest version then.
How can I a) upgrade to 9.3.1 (which is what the server version looks to be) or b) do one of these fixes like the one I attempted above which did not work.
I am very new to Postgresql so a step by step would be very helpful for me.
brew upgrade postgresql
brew link --overwrite postgresql
Solved by adding this at the end of my ~/.bash_profile ( or ~/.zshrc for zsh)
export PG_DUMP="/Applications/Postgres.app/Contents/Versions/9.6/bin/"
PATH=$PG_DUMP:$PATH
Don't forget to run (for bash shell)
$ source ~/.bash_profile
or (for zsh)
$ source ~/.zshrc
You can check the path of pg_dump by running
$ which pg_dump
==> /Applications/Postgres.app/Contents/Versions/9.6/bin//pg_dump
MacOS Mojave (10.14.2)
Postgres.app (2.1.5)
PostgreSQL 9.6
There are upgrade instructions you have to follow between Postgresql 9.2 and 9.3...
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
mv /usr/local/var/postgres /usr/local/var/postgres92
brew update
brew upgrade postgresql
initdb /usr/local/var/postgres -E utf8
pg_upgrade -b /usr/local/Cellar/postgresql/9.2.4/bin -B /usr/local/Cellar/postgresql/9.3.1/bin -d /usr/local/var/postgres92 -D /usr/local/var/postgres
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist