Search notes:

MySQL command line

Specifying the Password

Use -p to ask for password:
mysql -u userName -p dbName
Use -pSecret to specify password. Convenient but insecure, client will write mysql: [Warning] Using a password on the command line interface can be insecure..
mysql -u userName -pSecret dbName
Use environment variable MYSQL_PWD. The client does not issue a warning, but it is still insecure.
mysql -u userName dbName

Specifying the host

The host to be connected to can be specified with -h:
mysql -h foobar.xy -u rene -pSecretGarden

Executing an SQL script file

After the command line options, a script file can be «redirected» with < so that its content is executed by mySql.
mysql -u userName -pPassWord -D database < scriptFile.sql

mysql_config_editor

The best way to store passwords for later connection seems to be to use the mysql_config_editor which stores the authentication needed in a file named .mylogin.cnf. This file is located in the home directory in Unix and in %APPDATA\MySQL in Windows.
Enter a password:
c:\> "%programfiles%\MySQL\MySQL Server 8.0\bin\mysql_config_editor" set --login-path=client --host=localhost --user=rene --password
Remove it again:
C:\> "%programfiles%\MySQL\MySQL Server 8.0\bin\mysql_config_editor" remove  --login-path=client --user

Other command line options

Other comand line options that I like to use are

Index