Rate this article :
This article was useful to you ?
Yes
No
Vous avez noté 0 étoile(s)
Sommaire
Procédure
Using the command line web terminal to import or export databases and perform SQL queries is essential for database developers and administrators.
This documentation explains how to do this.
Prior to this documentation, we invite you to access your hosting's Web Terminal.
mysql
commandThe mysql
command is a command line tool used to interact with the MySQL database server. It allows users to connect to a database, execute SQL queries and manage databases.
General syntax
mysql -h [host] -u [user] -p
-h [host]
: specifies the host (server) address. The default is localhost
.-u [user]
: specifies the user name for the connection.-p
: requests the user's password.To connect to a MySQL server:
mysql -h example.com -u root -p
After typing this command, you will be asked to enter the password.
Once you have logged in, select a database:
USE database_name;
Running SQL queries
Run SQL queries. For example
SELECT * FROM table_name;
To import a database from a SQL file :
mysql -h example.com -u [user] -p [database_name] < file.sql
Exporting a database
To export a database to a SQL file, use mysqldump
:
mysqldump -h example.com -u [user] -p [database_name] > backup.sql
You can run an SQL command directly from the command line:
mysql -h example.com -u [user] -p -e "SHOW DATABASES;"
Here's a complete example of how to connect, select a database, run a query and exit:
mysql -h example.com -u root -p Enter password: ******** mysql> USE my_database; mysql> SELECT * FROM my_table; mysql> EXIT;
This guide covers the basic operations you can perform with the mysql
command, enabling you to manage your MySQL databases efficiently.
You now know how to :
mysql
command to connect to your database.Whether for day-to-day management or one-off tasks, mastering these commands will enable you to navigate the world of MySQL databases with ease. 🚀👨💻
Thank you for following us so far! If you have any questions, tips to share, or simply send in your feedback, please feel free to leave a comment below. Your input is valuable to us and to the community! 💬🙌
Rate this article :
This article was useful to you ?
Yes
No
1mn reading
How do I connect to the Web Terminal with LWS Panel? (ssh web console)
4mn reading
How can I use GIT with the Web terminal on my LWS shared hosting?
2mn reading
How to change the PHP version of the LWS Panel Web Terminal
0mn reading
What can I do on my WordPress site using the Web Terminal?