Mysql Command Line Client: Difference between revisions
Jump to navigation
Jump to search
Line 33: | Line 33: | ||
SELECT VERSION(); | SELECT VERSION(); | ||
... | ... | ||
</syntaxhighlight> | |||
Alternatively: | |||
<syntaxhighlight lang='bash'> | |||
mysql -u root -p<password> "SELECT VERSION()" 2>&1 | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 05:57, 30 March 2021
Internal
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> "SELECT VERSION()" 2>&1