I have a shell script that calls the mysql command with one parameter from an external file, it looks like this (and I saw this example in other resources):
mysql --user=root --password=`cat /root/.mysql`
Bit does not work:
Failed to connect to MySQL server: access denied for user 'root' @ 'localhost' (using password: YES).
I tried different quotes without success. How to convey this?
UPDATE 1: Found that I can pass a password without a space character. The problem is this, my root pass contains spaces.
Finally, this line works:
mysql --user=root --password="$(cat /root/.mysql)"
or
mysql --user=root --password="$(< /root/.mysql)"
The root password must be without quotes: bla bla bla
bla bla bla
, :
mysql cnf:
install -m 700 -d /srv/secrets/ install -m 600 /dev/null /srv/secrets/root@localhost.cnf editor /srv/secrets/root@localhost.cnf
client.password ini
[client] password="password"
mysql:
mysql \ --defaults-extra-file=/srv/secrets/root@localhost.cnf \ --user=root \ --host=localhost \ --no-auto-rehash
mysql_config_editor .
mysql_config_editor
$ mysql_config_editor set \ --login-path=name_of_connection \ --host=server.example.com \ --user=login_as_user \ --password
.mylogin.cnf .
mysql --login-path=name_of_connection dbname dbname server.example.com login_as_user
mysql --login-path=name_of_connection dbname
dbname
server.example.com
login_as_user
--login-path , --silent, --login-path /
--login-path
--silent
mysql_config_editor, mysql
mysql_config_editor set --login-path=dev --user=dbuser --host=localhost -p
, ,
mysql --login-path=dev
Try:
if [ $MYSQL_PASS ] then mysql -u "$MYSQL_ROOT" -p "$MYSQL_PASS" -e "SHOW DATABASES" else mysql -u "$MYSQL_ROOT" -e "SHOW DATABASES" fi
I'm not sure if this is possible, but you can definitely use the file configuration .
Source: https://habr.com/ru/post/1625260/More articles:Find argc and argv from a library - c ++Get servlet init parameters in servlet context listener - servletsЯвляется ли присваивание эквивалентным загрузке/хранению для std:: atomic - c++Visual Studio 2015: Enabling MSTest Magazine - DebuggingФоновое изображение не работает в Ionic/Javascript/Angular - javascriptHow to get heap size set in eclipse.ini file? - javaHow to implement a sticky header on mobile devices - arraysНеожиданный экспорт токенов Webstorm - node.jsSpark scala running - scalaTwitter Bootstrap popover not working on first click - javascriptAll Articles