我在 xampp 上使用 Linux,我在使用 MySQL 時遇到了問題。
當我使用這個命令時sudo /opt/lampp/lampp start,它會正確啟動一切,當我sudo service mysql start在 xampp 的 MySQL 已經運行時使用時,該命令給了我這個錯誤:
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
反之亦然,如果我sudo opt/lampp/lampp start在 MySQL 服務已經運行時使用此命令,我會在 PHPMyAdmin 頁面上收到此錯誤:
MySQL said:
Cannot connect: invalid settings.
mysqli::real_connect(): (HY000/2002): No such file or directory
Connection for controluser as defined in your configuration failed.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
除此之外:當我嘗試命令sudo mysqland 時show databases;,我得到的資料庫與 PHPMyAdmin 上的資料庫不同,所以這些是來自 MySQL 命令的資料庫:
Copyright (c) 2000, 2021, 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.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
--------------------
| Database |
--------------------
| Products |
| information_schema |
| mysql |
| performance_schema |
| sys |
--------------------
5 rows in set (0.00 sec)
MySQL>
但這些是我在 PHPMyAdmin 中的資料庫:
- 艾哈邁德
- 資訊模式
- mysql
- 性能模式
- phpmyadmin
- 產品
- 測驗
它們完全不同,當我在其中一個上創建資料庫時,它不會出現或存在于另一個上,它們彼此無關。
It seems very confusing for me, I don't know what to do, I've tried everything and I'm stuck with that for 4 days, and unfortunately, I'm not the kind of person that just goes on without understanding what's the problem, especially while I'm learning, so if anyone has a solution for this, that will be more than appreciated.
NOTE: I have searched a lot for the solution, Watched hours on youtube, and read and followed a lot of solutions that didn't work, and I also removed apache, Mysql, and xampp completely from my system and reinstalled it again, and nothing did work for me although it did with others, so I'm not here to waste anybody's time.
uj5u.com熱心網友回復:
關于缺少資料庫的問題:你確定你只運行 MySQL 嗎?你不是有兩個并排運行的資料庫引擎嗎?我不確定是否有可能讓(例如)MariaDB 和 MySQL 并排運行,但如果是這樣,這正是我期望發生的那種問題。畢竟,他們可能使用 80% 的相同路徑和檔案名。
我個人在手動安裝 MySQL(或 MariaDB)、Apache 和 PHP 方面有更好的體驗。然后使用 Docker 管理 PhpMyAdmin。然后你所要做的就是更改 PhpMyAdmin 的組態檔,它應該會在幾分鐘內順利運行。只是一個建議,我當然不知道您的設定和要求:-)
uj5u.com熱心網友回復:
這是找出解決方案后對我的問題的答案
解釋:
沒錯,它們是不同的Mysql資料庫,從phpMyAdmin中使用起來很簡單,但是mysqlcommand不會與xampp的Mysql鏈接,因為它們是不同的資料庫服務器。
從終端使用 xampp 的 Mysql:
使用以下命令停止不屬于 xampp 堆疊的 Mysql 服務:
sudo service mysql stop啟動 xampp:
sudo /opt/lampp/lampp start
現在您可以打開 phpMyAdmin 并從那里與您的 SQL 表進行互動。
要從終端打開 xampp 的 Mysql (MariaDB),請使用以下命令:
sudo /opt/lampp/bin/mysql -u root -p
如果您有 phpMyAdmin root 的密碼,請在它詢問您時輸入密碼,如果沒有,只需按 Enter。
這是你應該得到的:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.21-MariaDB Source distribution
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)]>
進入 Mysql 控制臺后,使用以下命令:
show databases;
我們開始了,您擁有與 phpMyAdmin 相同的資料庫。
這是xampps的Mysql,但另一個不是,不幸的是,這就是Mysql命令和phpMyAdmin的Mysql之間發生沖突的原因,這就是它們彼此不同的原因。
提示:您可以將此命令的別名sudo /opt/lampp/bin/mysql -u root -p轉換為mysql,只是為了使用簡單。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/330833.html
