0
judahmeek@Judahs-MBP dummy % mysql
ERROR 1045 (28000): Access denied for user 'judahmeek'@'localhost' (using password: NO)

Using Homebrew's latest mysql package on MacOS v13.1 with default terminal.

I'm a rather junior developer so I haven't made many unexpected system changes.

For example, here's my .zshrc:

judahmeek@Judahs-MBP dummy % cat ~/.zshrc

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

According to my search results, root should be the default username.

Does anyone have a clue why it's judahmeek instead?

Edit:

per @Barmar's suggestion, I ran the following:

judahmeek@Judahs-MacBook-Pro memseed % cat /etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
cat: /etc/my.cnf: No such file or directory
cat: /etc/mysql/my.cnf: No such file or directory
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
cat: /Users/judahmeek/.my.cnf: No such file or directory

Also according to mysql --help,

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}          Value (after reading options)
----------------------------------------- --------------------------------
auto-rehash                               TRUE
...-snip-...
user                                      (No default value)
...-snip-...
Judah Meek
  • 565
  • 7
  • 16
  • 1
    Look in your `.my.cnf` – Barmar Jan 19 '23 at 20:10
  • That's not saying the correct username is `judahmeek`. It's saying you tried to login using `judahmeek` and access was denied. – David Jones Jan 19 '23 at 20:13
  • 1
    @DavidJones I think he's asking why it used `judahmeek` when it tried to login. He didn't use `-u judahmeek` – Barmar Jan 19 '23 at 20:24
  • @Barmar I appreciate your suggestion. Please see my edit. I pulled all the possible `.cnf` locations from `mysql --help` according to https://stackoverflow.com/questions/2482234/how-do-i-find-the-mysql-my-cnf-location – Judah Meek Jan 19 '23 at 20:33
  • 1
    Do you have `~/.mylogin.cnf`? See https://dev.mysql.com/doc/refman/8.0/en/mysql-config-editor.html – Barmar Jan 19 '23 at 20:34
  • @Barmar I do not – Judah Meek Jan 19 '23 at 20:38
  • 1
    By default, it'll use your shell's username to connect. `mysql -u root` if you wanna change that. – ceejayoz Jan 19 '23 at 20:41
  • @ceejayoz You are correct. `On Unix, most MySQL clients by default try to log in using the current Unix user name as the MySQL user name` according to https://dev.mysql.com/doc/refman/8.0/en/user-names.html Feel free to post this as an answer so I can give you full credit. – Judah Meek Jan 19 '23 at 20:54
  • You receive *ERROR 1045 (28000): Access denied for user 'judahmeek'@'localhost' (using password: **NO**)*. This means that you do NOT provide a password during the authentication. Check does the command-line option [--password](https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_password) is used in the client command line. – Akina Jan 20 '23 at 05:21

0 Answers0