6

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.

Roberto Apasajja
  • 77
  • 1
  • 1
  • 4

2 Answers2

6

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

$ mysql -u root -p db1 -e "your-insert-here"
Khaled
  • 36,533
  • 8
  • 72
  • 99
6

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

mysql -u root -pz -e "USE db1; INSERT INTO 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);"
user9517
  • 115,471
  • 20
  • 215
  • 297