Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

MySQL details:

MySQL username: root
MySQL password: z

To run MySQL query without login, the command is:

mysql -u root -pz -e "mysql-query-here"

So, if I want to create database with name db1, it will become:

mysql -u root -pz -e "CREATE DATABASE db1 CHARACTER SET utf8 COLLATE utf8_bin"

Now, I want to run this query for database db1

INSERT INTO `role_permission` VALUES (1,'create about_us content','node')

I dont know how to make it works. I've tried many combinations without luck.

share|improve this question
up vote 5 down vote accepted

You can use the same command, but after adding the DB name like:

$ mysql -u root -p db1 -e "your-insert-here"
share|improve this answer

You can just add a use db1 command to the string you pass to mysql.

mysql -u root -pz -e "USE db1; INSERT INDO role_permissions values (1,'create about_us content','node');"

Also, did you create your role_permissions table e.g.

mysql -u root -pz -e "USE db1; CREATE TABLE role_permissions (id INT, data VARCHAR(200), type VARCHAR (10);"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.