- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we establish MySQL database by using MySQL binary at commandnprompt?
You can establish the MySQL database using the mysql binary at the command prompt. It can be understood with the help of the following example −
We can use following statements to connect to the MySQL server from the command prompt −
[root@host]# mysql -u root -p Enter password:******
This will give us the mysql> command prompt where we will be able to execute any SQL command. Following is the result of above command −
The following code block shows the result of above code −
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.20 MySQL Community Server (GPL) Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. 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.
In the above example, we have used root as a user but you can use any other user as well. Any user will be able to perform all the SQL operations, which are allowed to that user.
We can disconnect from the MySQL database any time using the exit command at mysql> prompt.
mysql> exit Bye
- Related Articles
- Print structured MySQL SELECT at command prompt
- After connecting to MySQL server how can we select a database from\ncommand prompt?
- How can we delete a MySQL database by using PHP script?
- How can we select a MySQL database by using PHP script?
- Getting MySQL path in command prompt
- What is MySQL CREATE command? How can we create both database and table with this command?
- How do we print a variable at the MongoDB command prompt?
- Write an example to establish MySQL database connection using PHP script?
- How can we analyze the tables of a particular database from MySQL Server command line?
- Which PHP function is used to establish MySQL database connection using PHP script?
- How can we get the list of tables in a particular database from MySQL Server command line?
- How can we create our own choice MySQL database?
- How can we return to windows command shell from MySQL command line tool?
- How can we change the default MySQL database to the given database?