1

I have to set up a local database on a number of people's Linux Mint lap- and desk-tops. The idea is to do this from the command line after installing MySQL Server and Client, and associated components. The command line I am looking for is something like:-

mysql -uuser -p database < schemafile.sql

However at this stage MySQL does not know about the database and I cannot work out the syntax to introduce it. Previously I have done this via Workbench but I do not want to install this as the users are only meant to populate their local database which will be exported down the line via a specific app that does numerous validations and cross-checks.

Thanks and regards...

1

Simple syntax to restore database is

mysql -uusername -hhostip/dns -ppassword databasename < dumpfile.sql

This should work fine.

0

To create the database, you use "CREATE DATABASE name_of_db;"

Before you import a schema you have to create it.

Either you create by hand previously the database in MySQL, or you had it to the top of your schemafile.sql

It is worth remembering also the necessary grants to establish access and rights.

"MySQL user manual - 3.3 Creating and Using a Database" http://dev.mysql.com/doc/refman/5.7/en/database-use.html

"How To Create a New User and Grant Permissions in MySQL"

https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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