Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

up vote 4 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

 
discard

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.