Mysql Command Line Client: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 2: Line 2:


* [[MySQL Operations#Command_Line_Client|MySQL Operations | Command Line Client]]
* [[MySQL Operations#Command_Line_Client|MySQL Operations | Command Line Client]]
=Options=
==-e, --execute=name==
Execute command and quit.


=Connect=
=Connect=

Revision as of 06:02, 30 March 2021

Internal

Options

-e, --execute=name

Execute command and quit.

Connect

mysql -u root -p

Will challenge for password.

mysql -u root -p<password>

No space after -p.

The username and password can also be stored in ~/.my.cnf:

[client]
user = root
password = XXXXXXXX

Scripting Database Interaction

mysql -u root -p<password> < statements.sql

where statements.sql should contain SQL:

SELECT VERSION();
...

Alternatively:

mysql -u root -p<password> -e "SELECT VERSION()" 2>&1