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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758207105, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/MySQL/command-line/index(78): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78