我正试图使用XAMPP conf文件中的用户通行证登录mysql,但我收到了以下错误:
mysql -u mysql -p; î² 1 â î² at 11:48:02 AM
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
我已进入
1234
作为conf文件中的密码
/Applications/XAMPP/xamppfiles/etc/my.cnf
下面是:
# The following options will be passed to all MySQL clients
[client]
password =1234
port =3306
socket =/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
default-character-set=utf8mb4
[mysqld]
user=mysql
port=3306
socket =/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
key_buffer=16M
max_allowed_packet=1M
table_open_cache=64
sort_buffer_size=512K
net_buffer_length=8K
read_buffer_size=256K
read_rnd_buffer_size=512K
myisam_sort_buffer_size=8M
此外,以下是运行mysql守护进程的信息:
ps aux | grep mysql î² PIPE|2 â î² at 11:55:38 AM
mona 6189 0.0 0.0 4286736 724 s003 S+ 11:56AM 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox mysql
_mysql 5707 0.0 0.0 4589008 8172 ?? S 11:53AM 0:00.10 /Applications/XAMPP/xamppfiles/sbin/mysqld --basedir=/Applications/XAMPP/xamppfiles --datadir=/Applications/XAMPP/xamppfiles/var/mysql --plugin-dir=/Applications/XAMPP/xamppfiles/lib/mysql/plugin/ --log-error=/Applications/XAMPP/xamppfiles/var/mysql/goku.err --pid-file=/Applications/XAMPP/xamppfiles/var/mysql/goku.pid --socket=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock --port=3306
root 5555 0.0 0.0 4308708 844 ?? S 11:53AM 0:00.02 /bin/sh /Applications/XAMPP/xamppfiles/bin/mysqld_safe --datadir=/Applications/XAMPP/xamppfiles/var/mysql --pid-file=/Applications/XAMPP/xamppfiles/var/mysql/goku.pid
以下是我在XAMPP中看到的内容:
我有OSX Catalina 10.15.7(19H1713)。
取消对密码的注释并将其设置为
1234
我在XAMPP UI中停止并启动了mySQL,但仍然无法登录。
我输入如下,但仍然没有进入mysqlshell:
mysql -u mysql -h 127.0.0.1 -port 3306 -p 1234;
我看到了这样的东西:
mysql: [Warning] Using a password on the command line interface can be insecure.
/usr/local/mysql/bin/mysql Ver 8.0.29 for macos12 on x86_64 (MySQL Community Server - GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Usage: /usr/local/mysql/bin/mysql [OPTIONS] [database]
-?, --help Display this help and exit.
-I, --help Synonym for -?
--auto-rehash Enable automatic rehashing. One doesn't need to use
'rehash' to get table and field completion, but startup
and reconnecting may take a longer time. Disable with
--disable-auto-rehash.
(Defaults to on; use --skip-auto-rehash to disable.)
在没有传递端口信息的情况下(因为3306是默认端口),我得到了这个错误,尽管
1234
是我在examplep的mysql-conf文件中设置的密码):
mysql -u mysql -h 127.0.0.1 -p; î² 1 â î² at 12:29:02 PM
Enter password:
ERROR 1045 (28000): Access denied for user 'mysql'@'localhost' (using password: YES)