![无法在 mariadb 服务器中使用 mysql,没有明确的原因](https://linux22.com/image/191101/%E6%97%A0%E6%B3%95%E5%9C%A8%20mariadb%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%AD%E4%BD%BF%E7%94%A8%20mysql%EF%BC%8C%E6%B2%A1%E6%9C%89%E6%98%8E%E7%A1%AE%E7%9A%84%E5%8E%9F%E5%9B%A0.png)
如果我只是输入 mysql -u root -p 并输入我的密码,我会进入我的数据库,但现在每次我说 mysql 和任何类似此输出的选项时,我仍然会收到一条消息
root@Dodge:~# mysql
Usage: /etc/init.d/mysql start|stop|restart|reload|force-reload|status
root@Dodge:~# mysql -u root
Usage: /etc/init.d/mysql start|stop|restart|reload|force-reload|status
root@Dodge:~# mysql -u root -p
Usage: /etc/init.d/mysql start|stop|restart|reload|force-reload|status
此消息意味着该服务未运行,对吗?但是当我运行状态时我得到服务处于活动状态
root@Dodge:~# systemctl status mysql
● mariadb.service - MariaDB 10.5.9 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (exited) since Thu 2021-05-13 10:33:27 EET; 16min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Tasks: 0 (limit: 9337)
Memory: 0B
CPU: 0
CGroup: /system.slice/mariadb.service
root@Dodge:~# systemctl status mariadb
● mariadb.service - MariaDB 10.5.9 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (exited) since Thu 2021-05-13 10:33:27 EET; 16min ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Tasks: 0 (limit: 9337)
Memory: 0B
CPU: 0
CGroup: /system.slice/mariadb.service
是活跃的所以为什么还给我
用法:/etc/init.d/mysql start|stop|restart|reload|force-reload|status
我尝试卸载每个 Thin 并重新安装它并安全安装并更新我的系统 - 我使用基于 debian 的 kali-linux 多年,没有任何问题。
编辑
当我运行 mysql status 时,我也会在底部看到此日志
ay 13 11:15:37 Dodge mariadbd[14041]: 2021-05-13 11:15:37 3 [Warning] Access denied for user 'roo…rd: NO)
May 13 11:15:37 Dodge mariadbd[14041]: 2021-05-13 11:15:37 4 [Warning] Access denied for user 'roo…rd: NO)
May 13 11:15:37 Dodge /etc/mysql/debian-start[14065]: /usr/bin/mysql_upgrade: the '--basedir' option…nored
May 13 11:15:37 Dodge /etc/mysql/debian-start[14065]: Looking for 'mysql' as: /usr/bin/mysql
May 13 11:15:37 Dodge /etc/mysql/debian-start[14065]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
May 13 11:15:37 Dodge /etc/mysql/debian-start[14065]: Version check failed. Got the following error …lient
May 13 11:15:37 Dodge /etc/mysql/debian-start[14065]: ERROR 1045 (28000): Access denied for user 'ro…: NO)
May 13 11:15:37 Dodge /etc/mysql/debian-start[14065]: FATAL ERROR: Upgrade failed
May 13 11:15:37 Dodge mariadbd[14041]: 2021-05-13 11:15:37 5 [Warning] Access denied for user 'roo…rd: NO)
May 13 11:15:37 Dodge debian-start[14078]: ERROR 1045 (28000): Access denied for user 'root'@'local…d: NO)
Hint: Some lines were ellipsized, use -l to show in full.
答案1
which mysql
返回/etc/init.d/mysql
。之所以如此,是因为/etc/init.d
它位于您的 PATH 之前,它具有在您键入时/usr/bin
执行的效果。/etc/init.d/mysql
mysql
您需要确保 mysql 客户端的位置位于/etc/init.d
PATH 之前。或者/etc/init.d
从路径中删除;我看不出它存在的任何原因。此外,要使此更改永久生效,您需要更改配置文件或 bashrc 文件中的 PATH 设置。
如果您有理由不更改 PATH 变量,则需要通过提供完整路径名来启动 mysql 客户端:/usr/bin/mysql
。