{"id":18427,"date":"2026-09-30T07:34:00","date_gmt":"2026-09-30T04:34:00","guid":{"rendered":"https:\/\/www.hyyat.com\/knowledgebase\/mysql-commands-ssh\/"},"modified":"2026-09-30T07:34:00","modified_gmt":"2026-09-30T04:34:00","password":"","slug":"mysql-commands-ssh","status":"publish","type":"docs","link":"https:\/\/www.hyyat.com\/en\/knowledgebase\/mysql-commands-ssh\/","title":{"rendered":"Basic MySQL Commands to Manage Databases over SSH"},"content":{"rendered":"<div class=\"hy-tldr\" style=\"background:#f6f7fb;border-left:4px solid #d83954;border-radius:10px;padding:14px 18px;margin:0 0 20px;line-height:1.8\"><strong>In short:<\/strong> To work with databases from the command line: connect over SSH, type mysql to log in, then show databases; to list databases, use DBNAME; to select one, and show tables; to list its tables. To create a database and user: CREATE DATABASE, then CREATE USER, then GRANT ALL PRIVILEGES, then FLUSH PRIVILEGES.<\/div>\n<p>You can manage databases directly from the shell, without phpMyAdmin, using the mysql client. First connect to your server over SSH (see <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/how-to-connect-to-a-server-via-ssh\/\">how to connect to your server over SSH<\/a>).<\/p>\n<h2>Browse databases<\/h2>\n<p>Log in to MySQL:<\/p>\n<pre>mysql<\/pre>\n<ul>\n<li>List databases: <code>show databases;<\/code><\/li>\n<li>Select a database: <code>use DBNAME;<\/code><\/li>\n<li>List its tables: <code>show tables;<\/code><\/li>\n<li>List a table&#8217;s columns: <code>show columns from TABLENAME;<\/code><\/li>\n<li>List the tables of another database: <code>show tables from DBNAME;<\/code><\/li>\n<li>Leave MySQL: <code>exit<\/code><\/li>\n<\/ul>\n<h2>Create a database and a user<\/h2>\n<p>Log in as root and enter the MySQL root password:<\/p>\n<pre>mysql -u root -p<\/pre>\n<pre>CREATE DATABASE DBNAME;\nCREATE USER 'DBUSER'@'localhost' IDENTIFIED BY 'DBPASS';\nGRANT ALL PRIVILEGES ON DBNAME.* TO 'DBUSER'@'localhost';\nFLUSH PRIVILEGES;\nexit<\/pre>\n<p>Replace DBNAME, DBUSER and DBPASS with your own values, and use a strong password.<\/p>\n<p><strong>Note:<\/strong> on cPanel servers, create databases and users from cPanel (MySQL Databases) so they are linked to the right account and included in its backups. To import a large .sql file, see <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/import-mysql-database-ssh\/\">how to import a MySQL database over SSH<\/a>.<\/p>\n<p class=\"hy-svc-link\" style=\"background:#fff5f7;border-left:4px solid #d83954;border-radius:10px;padding:14px 18px;margin:20px 0;line-height:1.8\"><strong>Related service:<\/strong> <a href=\"https:\/\/www.hyyat.com\/en\/server-management\/\">Hyyat Host server management<\/a> handles database administration on your server, with 24\/7 support.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In short: To work with databases from the command line: connect over SSH, type mysql to log in, then show databases; to list databases, use DBNAME; to select one, and show tables; to list its tables. To create a database and user: CREATE DATABASE, then CREATE USER, then GRANT ALL PRIVILEGES, then FLUSH PRIVILEGES. You [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"_templately_pack_id":"","_templately_imported_at":"","_templately_source":"","_templately_import_session_id":"","footnotes":""},"doc_category":[2733],"doc_tag":[],"class_list":["post-18427","docs","type-docs","status-publish","hentry","doc_category-servers-without-control-panel"],"year_month":"2026-10","word_count":229,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"ahmed fathy","author_nicename":"ahmed-fathy","author_url":"https:\/\/www.hyyat.com\/en\/author\/ahmed-fathy\/"},"doc_category_info":[{"term_name":"servers without control panel","term_url":"https:\/\/www.hyyat.com\/en\/kb\/servers-without-control-panel\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs\/18427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/comments?post=18427"}],"version-history":[{"count":0,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs\/18427\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/media?parent=18427"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/doc_category?post=18427"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/doc_tag?post=18427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}