Mysql Command Line Client: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 5: Line 5:
=Connect=
=Connect=


<pre>
<syntaxhighlight lang='bash'>
mysql -u root -p
mysql -u root -p
</pre>
</syntaxhighlight>
 
<syntaxhighlight lang='bash'>
mysql -u root -p<password>
</syntaxhighlight>
 
No space after -p.
 
The username and password can also be stored in ~/.my.cnf:
<syntaxhighlight lang='text'>
[client]
user = root
password = XXXXXXXX
</syntaxhighlight>
 
=Scripting Database Interaction=
 
<syntaxhighlight lang='bash'>
mysql -u root -p<password> < statements.sql
</syntaxhighlight>

Revision as of 02:07, 30 March 2021

Internal

Connect

mysql -u root -p
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