i found this code but do not quite understand what the command is doing.
sudo -u test-user mysql -U test_traffic traffic < ./phoenix/data/sql/lib.model.schema.sql
i know the last part is using lib.model.schema.sql to create the tables and fields
the first part i dont quite understand: sudo -u test-user mysql -U test_traffic traffic
i know the command sudo and mysql
please explain?
thanks
Let’s look at it bit by bit. Firstly the format
is an instruction to run
command(which might be simple or complex) as the userusername. So in your example, you are running themysqlcommand as the usertest-user. You should note that this includes all the parameters to themysqlcommand – that’s the entire rest of the line.The command
appears corrupt (certainly running it on 5.0.51a fails). It would make sense if the
-Uwas a-uwhich would indicate that that the command was to be executed for mysql usertest_traffic. If it was a-uyou would then have an instruction to import the sql file into the traffic database.So the combined instruction says, import the
lib.model.schema.sqlfile into the databasetest_trafficusing the mysql usertest_trafficand executing the entire command as if you were logged-in as the usertest-user.