Kali-Linux

在沒有明確原因的情況下無法在 mariadb 伺服器中使用 mysql

  • May 13, 2021

如果我只是輸入 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

我試圖解除安裝每一個瘦並重新安裝它並安裝安全並更新我的系統 - 我使用基於 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.

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從 PATH 中移除;我看不出它存在的任何原因。此外,要使此更改永久生效,您需要更改配置文件或 bashrc 文件中的 PATH 設置。

如果您有理由不更改 PATH 變數,則需要通過提供完整路徑名來啟動 mysql 客戶端:/usr/bin/mysql.

引用自:https://unix.stackexchange.com/questions/649496