Thanks to visit codestin.com
Credit goes to github.com

Skip to content

This document describes the core features of MySQL Shell.

Notifications You must be signed in to change notification settings

thotho19/mysql_shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 

Repository files navigation

Chapter 1 MySQL Shell Features

Supported Languages

MySQL Shell processes code written in JavaScript, Python and SQL. Any executed code is processed as one of these languages, based on the language that is currently active.

Interactive Code Execution

Unicode text input is supported if the terminal in use supports it. Color terminals are supported.

Supported APIs

The AdminAPI enables you to administer MySQL instances, using them to create InnoDB Clusters
The X DevAPI enables developers to work with both relational and document data when MySQL Shell is connected to a MySQL server using the X Protocol.

Utilities

MySQL Shell includes the following utilities for working with MySQL:

  1. An upgrade checker utility to verify whether MySQL server instances are ready for upgrade. Use util.checkForServerUpgrade() to access the upgrade checker.

  2. A JSON import utility to import JSON documents to a MySQL Server collection or table. Use util.importJSON() to access the import utility.

  3. A parallel table import utility that splits up a single data file and uses multiple threads to load the chunks into a MySQL table.

Output Formats

MySQL Shell can return results in table, tabbed, or vertical format, or as JSON output. 5.7 Output Formats

Chapter 2 MySQL Shell Commands

Command Alias/Shortcut Description Syntax
\help \h or ? Print help about MySQL Shell, or search the online help. \? \connect
\quit \q or \exit Exit MySQL Shell.
\ In SQL mode, begin multiple-line mode.
\status \s Show the current MySQL Shell status.
\js , \py , \sql Change execution mode
\connect \c Connect to a MySQL instance. \connect --mysql root:[email protected]:3306 or \connect --mysql root:[email protected]:33060
\reconnect Reconnect to the same MySQL instance.
\disconnect Disconnect the global session.
\use \u Specify the schema to use.
\source . or source (no backslash) Execute a script file using the active language.
\warnings \W Show any warnings generated by a statement.
\nowarnings \w Do not show any warnings generated by a statement.
\history View and edit command line history.
\option Query and change MySQL Shell configuration options..
\show Run the specified report using the provided options and arguments. show query [OPTIONS] [ARGS] or \watch query [OPTIONS] [ARGS]
\edit \e Open a command in the default system editor then present it in MySQL Shell.
\pager \p Configure the pager which MySQL Shell uses to display text.
\nopager Disable any pager which MySQL Shell was configured to use.
\system ! Run the specified operating system command and display the results in MySQL Shell.

Chapter 3 MySQL syntax

Command Description Syntax
show databases show all created database show databases
show tables show all created tables inside the database show tables
desc {tableName} view table schema desc {tableName}
insert into {tableName} (column1 , column2 ... ) values (value1 , value2 ...) Insert to database table insert into mygames (id , gameName) values (1 , "CAll Of Duty: WarZonew
delete from {tableName} delete all the rows and reutrn the number of deleted rows delete from mygames
alter table {tableName} modify {columnName} {column_definition} modify table schema alter table mygames modify gameName varchar(300)
create user {userName}@{ipAddress} Create user create user [email protected]
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’; alter user ALTER USER [email protected] IDENTIFIED WITH mysql_native_password BY ‘Nodejs1997!’;
grant all on {databaseName}.* to {userName}@{ipAddress}; Grant a database privilages to anothe user grant all on test_db.* to [email protected];
show grants for {userName}@{ip address}; Show all granted privileges show grants for [email protected]
Constraint esablishing Create talbe with constarint create table projects (pid int not null, constraint project_const primary key(pid));
auto increment create a talbe with auto incremet create table projects (pid int not null auto_increment,pname text not null , constraint project_const primary key(pid));
multi constraint create double constraint table create table enroll (tid int not null,pid int not null, constraint enroll_const foreign key(tid) references teachers(tid) , foreign key(pid) references projects(pid));
Inner join innner join between three tables select users.uname , games.gname from link inner join users on (users.uid = link.uid) inner join games on (games.gid = link.gid);
show index show all avaliable index for specific table show index from {table name}
delimiter delimiter is the marker for the end of each command you send to the mysql command line client. delimite \\ ... the remaining code
create procedure example Empty delimiter // create procedure display_book() -> begin -> select *from book; -> end // call display_book(); //

Important

Under some circumstances, CREATE USER may be recorded in server logs or on the client side in a history file such as ~/.mysql_history, which means that cleartext passwords may be read by anyone having read access to that information. For information about the conditions under which this occurs for the server logs and how to control it, see Section 6.1.2.3, “Passwords and Logging”. For similar information about client-side logging, see Section 4.5.1.3, “mysql Client Logging”.

SET PASSWORD = 'auth_string';

Any client who connects to the server using a nonanonymous account can change the password for that account. (In particular, you can change your own password.) To see which account the server authenticated you as, invoke the CURRENT_USER() function:

Reference - Mysql Documentation

About

This document describes the core features of MySQL Shell.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published