简体   繁体   中英

How can I access phpMyAdmin through terminal

I try to create a database through terminal in a laravel project and it tells me that the database is created but when I go to phpMyAdmin I can not find it.

mysql> create database house
-> ;
Query OK, 1 row affected (0.06 sec)

mysql> SHOW DATABASES;
ERROR 1449 (HY000): The user specified as a definer ('mysql.infoschema'@'localhost') does 
not exist

I was using MAMP and it did not work so I used Xamp and it did not work also, and when I run:

mysql> select user from mysql.user
-> ;
+------------------+
| user             |
+------------------+
| mysql.infoschema |
| mysql.session    |
| mysql.sys        |
| root             |
| user             |
+------------------+
5 rows in set (0.01 sec)

it gives me another users not existed in MAMP phpMyAdmin or Xamp phpMyAdmin.

Is there a way to connect successfuly to MAMP or XAMP phpMyAdmin.

Note:

IP address for Laravel project: 127.0.0.1 the same with MAMP but IP address for Xamp is: 192.168.64.2

Here is my.env file:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=pizzahouse
DB_USERNAME=root
DB_PASSWORD=

Somehow, your MySQL user permissions are damaged (mysql.infoschema is a system user for MySQL to use internally). Why it exists but can't be used internally by MySQL isn't clear, but the error message shows that this internal user is damaged. The easiest way to recover from this is to reinstall MySQL (through XAMPP or WAMP or whichever package you end up selecting). You'll need to make sure to remove the entire MySQL data directory (which the uninstaller should either do automatically or ask you about, I don't recall which). Note that this will destroy any existing data in your database so you should not proceed if you have existing data you wish to preserve.

When you reinstall, MySQL will properly configure these required system users and you should be back up and running.

You should not usually run XAMPP and WAMP along side each other, since they more or less serve the same general purpose and you're at risk for them competing for the same ports and (potentially) MySQL's data directory. That could be what happened here, although there isn't really enough information to know. MySQL uses a "data directory" (datadir) to hold on disk all the database files. It's plausible (although perhaps unlikely) that your two servers (XAMPP and WAMP) have both ended up using the same path which would cause corruption of the databases, tables, and users. Aside from that, some freak server crash, disk corruption, or incorrect SQL command could have caused the problem as well.

It may be possible to restore the existing system users with a command such as mysqld --initialize --user=mysql ( documentation , and note that you'll need to reset the root password on next login), but with this degree of uncertainty, I think it's an all-around safer option to reinstall from scratch — again pointing out that this will destroy any data that already exists in your database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM