0

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]> 
  • What user is your last `show tables` running as, edit question to include `\s` information. How did you "dropped root users and other local users"? If you deleted the mysql database tables that wasn't a good move. use `drop user` if you need to. Might be easier to stop mariadb, `rm -rf /usr/local/var/mysql/*` and `mariadb-install-db --user mysql --datadir /usr/local/var/mysql`. – danblack Aug 14 '22 at 07:29
  • Thanks your comment, I found that I can login to local MariaDB server with `mysql` command after I restart my computer. Therefore, I changed my root password and I can login with root user. – Marvin Wu Aug 16 '22 at 09:11

0 Answers0