Skip to main content
103 votes

How to pass password to mysql command line

The mysql client utility can take a password on the command line with either the -p or --password= options. If you use -p, there must not be any blank space after the option letter: $ mysql -...
Kusalananda's user avatar
  • 339k
39 votes

Get a progress indicator when importing MySQL databases

Why so complicated ? This works fine : pv dump.sql.gz | zcat | mysql -u user -ppasswd database
Vincent's user avatar
  • 491
36 votes
Accepted

Why does piping `mysql` to 'tail' change the output format?

It's not tail, it's the piping. mysql uses a tabular with ASCII boxing output format when its stdout is a terminal device, when it's intended for a user, and reverts to a scripting format when it's ...
Stéphane Chazelas's user avatar
31 votes

Suppress warning messages from MySQL in shell script but allow errors

In your bash script, edit it at top export MYSQL_PWD=yourdbpassword and mysql query like: mysql -u username -h host db -e "statement" Reference: From answer posted at Stackoverflow. Other answers ...
d a i s y's user avatar
  • 523
25 votes
Accepted

How to change MySQL 'root' password using MySQL v5.7?

In MySQL 5.7, the password field in mysql.user table field was removed, now the field name is authentication_string. First choose the database: mysql> use mysql; And then show the tables: ...
Rahul's user avatar
  • 13.7k
24 votes

install mysql - has no installation candidate

sudo apt install mariadb-server
Tamil's user avatar
  • 497
21 votes
Accepted

What are dbgsym packages?

The dbgsym package contains debug symbols. TLDR Ignore the dbgsym package Details If your program (mysql in this case) is written in a compiled language such as C, C++, Go, Rust, etc and converted ...
icarus's user avatar
  • 18.2k
17 votes

Ubuntu 18.04 LTS: Problem with dependencies installing MySQL 8.0 server

This fixed it for me (MySQL 8.0 - Ubuntu 20.04) sudo apt-get purge mysql\* libmysql\* sudo apt autoremove But the package "mysql-client-core-8.0" don't uninstall, so... sudo apt --fix-...
Cesar Devesa's user avatar
16 votes

install mysql - has no installation candidate

If you navigate the http://repo.mysql.com/apt/debian/pool/ repo, you'll find various versions available. It looks like mysql-server-5.6 was a metapackage, which is not there any longer. However, to ...
Lizardx's user avatar
  • 3,078
15 votes
Accepted

MySQL installed but no mysql command found

There are 2 metapackages: mysql-server and mysql-client. Looks like you have only the server pakage installed. That is at least how it works in Debian. Try installing mysql-client
Martin Vegter's user avatar
15 votes
Accepted

Debian 9: After upgrade from 8, MySQL (MariaDB) does no longer work

For some reason you don't have the file /etc/mysql/debian-start, which is the error given: 16:55:25 doraemoe systemd[6859]: mariadb.service: Failed at step EXEC spawning /etc/mysql/debian-start: No ...
wurtel's user avatar
  • 16.2k
14 votes
Accepted

How do I capture a MySQL result set in a bash array?

With the --batch option, mysql should output the result one record on a line, and columns separated by tabs. You can read the lines to an array with Bash's mapfile and process substitution, or command ...
ilkkachu's user avatar
  • 141k
12 votes

How to pass password to mysql command line

create a file ~/.my.cnf, make it only accessible by yourself, permission 600. [client] user=myuser password=mypassword Then you don't need type password any more. bash$ mysql -u myuser ...
oldpride's user avatar
  • 231
11 votes

error processing package mysql-community-server during apt-get upgrade

It looks as though the installation was interrupted in an earlier session. Try sudo apt-get install -f to see if it will fix broken dependencies. If that fails, purge MySQL server: sudo apt-get ...
gracious1's user avatar
  • 629
10 votes

Install libmysqlclient on CentOs 7

Try yum install mariadb-devel for CentOS 7
Eranga Atugoda's user avatar
9 votes

Install libmysqlclient on CentOs 7

yum whatprovides can find package with specific command or lib, for example: sudo yum whatprovides libmysqlclient* 1:mariadb-libs-5.5.56-2.el7.i686 : The shared libraries required for ...
c ccx's user avatar
  • 109
9 votes

Any work-around to pipe zip files?

If you are open to alternative compression tools, try this almost identical alternative. drt="/var/www/html" mysqldump -u root -p --all-databases | gzip >"$drt/db-$date.gz" If you prefer you can ...
Chris Davies's user avatar
8 votes

How to pass password to mysql command line

You can use a nifty Linux trick... /dev/stdin can be used as a file resource for --defaults-file like so: echo -e "[client]\nuser=xxx\npassword=xxx" | mysql --defaults-file=/dev/stdin -e '...
Danny Kopping's user avatar
8 votes
Accepted

Mysql queries from bash file

Try this ;) user="jonnDoe" dbname="customers" password="VerySecret" mysql -u $user -D $dbname -p $password -e "select Col1 from Table1 where Condition;" > /home/$user/queries/Col1Table1Cond mysql ...
Gilles Quénot's user avatar
8 votes
Accepted

How to disable Apache and MySQL autostart when PC is turned on?

You should disable them using either systemctl (if you're using systemd) or update-rc.d: systemctl disable apache2 mysql or update-rc.d apache2 disable update-rc.d mysql disable
Stephen Kitt's user avatar
8 votes
Accepted

After fresh install of mysql-server, can't log in with `mysql root -u`

1) you can try to reconfigure the mysql-server : sudo dpkg-reconfigure mysql-server 2) check if you have the debian-sys-maint passwd cat /etc/mysql/debian.cnf and check for : user = debian-...
f35's user avatar
  • 271
8 votes
Accepted

Changing password of postfix user account directly in the MySQL database

The $1$ at the beginning of the password field hints it is a MD5 hash. To encrypt a password in a MD5 hash, you can use the openssl passwd command. From man openssl: passwd Generation of ...
Rui F Ribeiro's user avatar
8 votes

Failed to connect to MySQL: No such file or directory

I believe the issue here is that localhost is not your database host. If that PHP script is running in the "www" docker container, localhost most likely does not have a listening MySQL server. IIRC, ...
GracefulRestart's user avatar
7 votes

How to pass password to mysql command line

As @maxschlepzig said in a comment, Note that there is the MYSQL_PWD environment variable which is read by mysql if you don't specify -p. So in bash: read -s -p "Enter the mysql password for $...
commonpike's user avatar
7 votes

MySQL root account without password?

By default Debian/Ubuntu/Mint has a user with administrative accesses, namely used to shutdown MySQL, called debian-sys-maint. Go to the file /etc/mysql/debian.cnf which has as the format: [client] ...
Rui F Ribeiro's user avatar
7 votes
Accepted

Use a password in shell-script

Put something like: [client] user=root password="my-very-secret-password" In a file whose permissions ensure that nobody outside the people who are entitled to read it can read it. And run: #! /...
Stéphane Chazelas's user avatar
7 votes

Preventing any external mysql login tries

Just let mysqld listen on loopback only e.g in /etc/mysql/my.cnf add or change the following configuration bind-address 127.0.0.1 In that way only programs that runs locally can connect to mysql ...
daisy's user avatar
  • 54.8k
7 votes

ERROR 1524 (HY000): Plugin 'unix_socket' is not loaded mysql

I've ran into a similar problem and got it working using this solution. STEP 1: ADD UNIX AUTHENTICATION PLUGIN TO MARIADB CONFIG Change the file /etc/mysql/mariadb.conf.d/50-server.cnf Add the line ...
user10089632's user avatar
7 votes

How do I capture a MySQL result set in a bash array?

Another way to do it would be to pipe the output of the command to a while loop. Note you want to include the -N or the results include the column name. #!/bin/bash #Script to read output from a ...
Joe M's user avatar
  • 876
7 votes
Accepted

error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory

Apparently the program was compiled against a version of MySQL downloaded from www.mysql.com; libmysqlclient.so.20 was not available in Debian. You can download a .deb from https://dev.mysql.com/...
wurtel's user avatar
  • 16.2k

Only top scored, non community-wiki answers of a minimum length are eligible