mysql -uusername -ppassword -h127.0.0.1
ERROR 1698 (28000): Access denied for user 'andrew'@'localhost'
找到mariadb的安装位置
whereis mariadb
没有反应
which mariadb
/usr/local/bin/mariadb
查看具体的位置
andrew@hackintosh:~#ll /usr/local/bin/mariadb
lrwxr-xr-x 1 andrew admin 37B 6 22 23:42 /usr/local/bin/mariadb -> ../Cellar/mariadb/10.4.13/bin/mariadb
andrew@hackintosh:~#../Cellar/mariadb/10.4.13/bin/mariadb
进入具体的位置
cd /usr/local/Cellar/mariadb/10.4.13#
ll
total 336
-rw-r--r-- 1 andrew staff 18K 5 10 03:28 COPYING
-rw-r--r-- 1 andrew staff 2.3K 5 10 03:28 CREDITS
-rw-r--r-- 1 andrew staff 8.1K 5 10 03:28 EXCEPTIONS-CLIENT
-rw-r--r-- 1 andrew staff 8.6K 6 22 23:42 INSTALL-BINARY
-rw-r--r-- 1 andrew staff 1.6K 6 22 23:42 INSTALL_RECEIPT.json
-rw-r--r-- 1 andrew staff 19K 5 10 03:28 README-wsrep
-rw-r--r-- 1 andrew staff 3.0K 5 10 03:28 README.md
-rw-r--r-- 1 andrew staff 84K 5 10 03:28 THIRDPARTY
drwxr-xr-x 87 andrew staff 2.7K 6 22 23:42 bin
-rw-r--r-- 1 andrew staff 541B 6 22 23:42 homebrew.mxcl.mariadb.plist
drwxr-xr-x 3 andrew staff 96B 5 10 03:28 include
drwxr-xr-x 12 andrew staff 384B 5 10 03:28 lib
drwxr-xr-x 3 andrew staff 96B 5 10 03:28 libexec
drwxr-xr-x 4 andrew staff 128B 6 22 23:42 scripts
drwxr-xr-x 7 andrew staff 224B 5 10 03:28 share
drwxr-xr-x 10 andrew staff 320B 6 22 23:42 support-files
有一个配置文件
增加这一条
–bind-address=0.0.0.0
homebrew.mxcl.mariadb.plist
vim homebrew.mxcl.mariadb.plist
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>homebrew.mxcl.mariadb</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/opt/mariadb/bin/mysqld_safe</string>
<string>--datadir=/usr/local/var/mysql</string>
<string>--bind-address=0.0.0.0</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>/usr/local/var</string>
</dict>
</plist>
重启mariadb
brew services restart mariadb
但是依然不能登入
```python
mysql -uusername -ppassword -h127.0.0.1
ERROR 1698 (28000): Access denied for user 'andrew'@'localhost'
但是问题来了
诡异
mysql -uusername -ppassword -hlocalhost
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 23
Server version: 10.4.13-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.
mysql -uuasername -ppassword -h192.168.28.94
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 19
Server version: 10.4.13-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)]>
成功
ps
设置用户权限即可解决问题
mysql -uusername -ppassword
use mysql;
MariaDB [mysql]> drop user 'andrew'@localhost;
Query OK, 0 rows affected (0.002 sec)
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%'IDENTIFIED BY 'password' WITH GRANT OPTION;
flush privileges;
``
再次登入ok