skip to Main Content

I’m using Linux with xampp, I have a problem with MySQL.

When I use this command sudo /opt/lampp/lampp start, it starts everything correctly, and when I use sudo service mysql start when MySQL of xampp is already running, the command gives me this error:

Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.

And vice versa, if I use this command sudo opt/lampp/lampp start while MySQL service is already running, I get this error on PHPMyAdmin page:

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.

In Addition to that: when I try the command sudo mysql and show databases;, I get different databases than what’s there on PHPMyAdmin, so these are databases from MySQL command:

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> 

But these are my databases in PHPMyAdmin:

  • Ahmed
  • information_schema
  • mysql
  • performance_schema
  • phpmyadmin
  • Products
  • test

They’re totally different, and when I create a database on one of them, it doesn’t appear or exist on the other, they’ve nothing to do with each other.

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.

2

Answers


  1. Chosen as BEST ANSWER

    This is the answer to my question after figuring out the solution

    Explanation:

    It was true that they're different Mysql databases, and it's quite simple to use it from phpMyAdmin, but mysql command won't be linked with Mysql of xampp because they're different database servers.

    To use Mysql of xampp from the terminal:

    • Stop the Mysql service which doesn't belong to xampp stack using this command:

      sudo service mysql stop

    • Start xampp:

      sudo /opt/lampp/lampp start

    Now you can open phpMyAdmin and interact with your SQL tables from there.

    • To open Mysql (MariaDB) of xampp from the terminal, use this command:

      sudo /opt/lampp/bin/mysql -u root -p

    If you have a password for phpMyAdmin root, type it when it asks you, if you don't, just hit enter.

    This is what you should get:

    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)]> 
    
    • Once you're inside Mysql console use the command:

      show databases;

    And here we go, you have the same databases that you have on phpMyAdmin.

    This is xampps' Mysql, but the other wasn't, and unfortunately, this was the reason for that conflict between Mysql command and Mysql of phpMyAdmin and that's why they were different from each other.

    Tip: You can make an alias for this command sudo /opt/lampp/bin/mysql -u root -p turn it into mysql, just for simplicity of usage.


  2. Concerning the missing database problem: are you sure you are only running MySQL? Don’t you have two database engines running side by side? I’m not sure it’s possible to have (for example) MariaDB and MySQL running side by side, but if it is, this would be exactly the kind of problem I would expect to occur. After all, they probably use 80% of the same paths and filenames.

    I personally have a better experience with manually installing MySQL (or MariaDB), Apache and PHP. Then manage PhpMyAdmin with Docker instead. All you then have to do, is change the config file for PhpMyAdmin and it should all be running smoothly in a matter of minutes. Just a suggestion, I don’t know your setup and requirements of course 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search