We use hg log -u MyUser.
Is there a way to make this case insensitive? Ie: so hg will return all changesets for MyUser or myuser.
I don't think there's a way to make the option case insensitive, but you can specify multiple user on the command line :
hg log -u MyUser -u myuser -u Myuser -u myUser
I admit this is a little bit tedious, but you can create an alias if you have to type the command many times. Add this to your hgrc file for example :
[alias]
mylog = log -u MyUser -u myuser -u Myuser -u myUser
You can now use hg mylog insteand of the entire expression.
Related
I want to copy a Database without copying its data, I mean I just want to copy the stucture and tables and foreign key and ... not the data in it.
The answer is here but I do not know where should I copy it ? In shell? In workbench? In query?
I entered it in query in workbenck and it has error !
Thank you in advance!
Edit
When I run it in my mysql shell I get this:
MySQL JS > mysqldump -u myusername -pmypassword -d olddb | mysql -u myusername -pmypassword -D newdb
SyntaxError: Unexpected identifier.
You'll need to run it on the command line for your OS (not the shell for MySQL as you tried earlier).
Under Linux (including Macs) it would look something like:
smm#smm-HP-ZBook-15-G2:~/$ mysqldump -u myusername -pmypassword -d olddb | mysql -u myusername -pmypassword -D newdb
Under Windows:
C:\> mysqldump -u myusername -pmypassword -d olddb | mysql -u myusername -pmypassword -D newdb
This is assuming mysqldump is in the PATH for your command line (it isn't if you get a command not found error). How to use a command line and set up the PATH depends on the OS and is beyond the scope of this answer.
Refer following links..
1) Create dump file
2) Reload dump file
I want to backup all privileges related to specific user (for example u_1) from a MySQL database and restore that in another server. As described here, The 'mysql' database contains users/privileges/passwords. So I have to backup all related data from all tables of mysql database (mysql.user,mysql.db, ...). I can run this command:
$ mysqldump -u root --flush-privileges -r mysql.sql -p mysql
But of course the mysql.sql contains all users and all privileges.
Also I tried this command:
$ mysqldump -u root -p --where="user.user='u_1'" mysql user> mysql.sql
But as expected, it only contains a row of mysql.user table.
Is there a way to strip out other users except of u_1?
Try these options (line breaks for clarity):
$ mysqldump -u root -p
--where="user='u_1'"
--complete-insert
--extended-insert
--no-create-info
mysql
user db tables_priv columns_priv procs_priv proxies_priv
> mysql.sql
Or... let's call the above solution "the hard way."
This should be the easy way:
$ mysql -u root -p
--skip-column-names
-e "SHOW GRANTS FOR 'u_1';"
> grants.sql
I would use:
pt-show-grants --only u_1
pt-show-grants is a tool in the free Percona Toolkit.
See https://www.percona.com/doc/percona-toolkit/LATEST/pt-show-grants.html
I am running the most recent version of MariaDB on a CentOS7 machine. I have two databases I need to back up. One for Postfix/Dovecot and Another for Wordpress. I have read a few guides and most just say that I should be good running
sudo mysqldump -h 127.0.0.1 -u root -p somepassword --all_databases > /tmp/backup.sql
Produces the output
Usage: mysqldump [OPTIONS] database [tables]
OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR mysqldump [OPTIONS] --all-databases [OPTIONS]
However, I suspect wordpress is complicating this process a bit because my CLI input is rewritten as
sudo mysqldump -h 127.0.0.1 -u root -p SomeIncorrectPassword find /var/www/somewordpressdir/wordpress/ -type d -exec chmod 755 {} \;! --all-databases > /tmp/backup.sql
I'm not sure why this is happening and I didn't come across anything similar. I am clearly missing something very basic here. What additional options do I need to provide?
I was reading an article that used the
--single_transaction
tag and this produced a different output
mysqldump: You can't use --single-transaction and --lock-all-tables at the same time.
it's not "--all_databases" with underscore but it's "--all-databases" with minus :-)
I need to change the temporary root password that is created when the MySQL daemon is started. The problem is that the temporary password has some weird characters (e.g. like a left/right parenthesis) that needs to be escaped. Now, there are several posts (here, here, here) on how to escape characters, in general, but this post is in the context of using a bash script to change the temporary MySQL root password that may have special characters.
Currently, my script looks like the following.
function startMysql {
sudo service mysqld start
echo "started mysql"
export PW=$(grep 'temporary password' /var/log/mysqld.log | awk '{print $11}')
# export PASS=\'$PW\'
echo "temporary password is $PW"
mysqladmin -u root -p$PW password aaBB##cc1122
# the following doesn't work either
# mysqladmin -u root -p$PASS password aaBB##cc1122
echo "changed mysql password"
}
Note that the temporary password may look like the following.
BYkc*),ZM3-_
If I type in the following on the terminal, it works.
mysqladmin -u root -p'BYkc*),ZM3-_' password aaBB##cc1122
But inside the script, it fails. Here are some ways that I have tried to put single quotes around $PW without success.
mysqladmin -u root -p"'$PW'" password aaBB##cc1122
mysqladmin -u root -p\''$PW'\' password aaBB##cc1122
mysqladmin -u root -p"$PW" password aaBB##cc1122
mysqladmin -u root -p"\"$PW\"" password aaBB##cc1122
Any ideas on what I am doing wrong?
It does work for me using double-quotes:
password=$(grep 'temporary password' /var/log/mysqld.log | awk '{print $11}')
mysqladmin --user=root --password="$password" password aaBB##cc1122
In a simple script like this one:
set -x
# Check if db exists, if not we make it, make user, give privileges
if ! mysql -u root -p -e "use $db" 2>/dev/null; then
c1="CREATE DATABASE $db"
c2="GRANT ALL PRIVILEGES ON ${db}.* to '$username'#'localhost' IDENTIFIED BY '$password'"
c3="FLUSH PRIVILEGES"
mysql -u root -p -e "$c1; $c2; $c3"
else
echo 'DATABASE ExISTS, ABORTING'; exit $DB_EXISTS
fi
I am asked each time, bash sees mysql command, for my root credentials.
Is there a way to avoid that, so that once entered the root password, all
additional mysql commands execute seamlessly?
Try looking into adding password to ~/.my.cnf
[client]
user = root
password = XXXXXXXX
Check out :
How to execute a MySQL command from a shell script?
Specifying the --password argument
mysql -u root --password=my_mysql_pass db_name
Safer using a bash variable
mysql -u root --password=$MYSQL_PASS db_name