You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MySQL登录后无法查看数据库及表结构的技术求助

How to View MySQL Schema/Tables When Root Login Only Shows "mysql"

Hey there! I’ve run into this exact situation before—let’s walk through the fixes you can try right away:

Command Line Client Fixes

If you’re using the native MySQL command line shell (the one showing the mysql> prompt):

  • First, list all available databases to confirm what’s accessible:
    SHOW DATABASES;
    
    This will return every database your root account has permissions to view, including the mysql system database you’re seeing now.
  • Switch to the database you need to inspect:
    USE your_target_database_name;
    
    Replace your_target_database_name with the actual name of the database you want to work with.
  • Now list all tables in this database:
    SHOW TABLES;
    
  • To view the full structure of a specific table, use either of these commands:
    -- Basic table structure (columns, data types, constraints)
    DESCRIBE your_table_name;
    
    -- Detailed create statement (includes indexes, engine settings, full constraints)
    SHOW CREATE TABLE your_table_name;
    

GUI Tool Fixes (e.g., MySQL Workbench, phpMyAdmin)

If you’re using a graphical tool and only see the mysql database:

  • Refresh the database list: Most tools have a refresh button (usually an arrow icon) in the left-side databases panel. Click it to load all available databases.
  • Check connection settings: Ensure your connection isn’t restricted to a single database. In MySQL Workbench, this can be adjusted under the connection’s "Advanced" settings.
  • Flush privileges: Sometimes permission caches cause visibility issues. Run this command in the tool’s query editor to refresh:
    FLUSH PRIVILEGES;
    

Quick Troubleshoot Note

  • If you logged in without specifying a default database (e.g., mysql -u root instead of mysql -u root -D your_database), you’ll start in a "neutral" state where only system databases like mysql are visible until you run the USE command to switch to your target database.
  • Double-check your root account has full permissions by running:
    SHOW GRANTS FOR 'root'@'localhost';
    
    You should see a line granting ALL PRIVILEGES ON *.* to your root user.

内容的提问来源于stack exchange,提问作者Alex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:23:24