sed -i 's/OLDDATABASENAME/NEWDBNAME/g' mysqldumpFile.sql
Then run:
mysql -p create NEWDBNAME; use NEWDBNAME; SOURCE /path/to/sql/fileNo need for a semicolon on the last line. Then check the success by:
show tables;
Websites and SEO
sed -i 's/OLDDATABASENAME/NEWDBNAME/g' mysqldumpFile.sql
Then run:
mysql -p create NEWDBNAME; use NEWDBNAME; SOURCE /path/to/sql/fileNo need for a semicolon on the last line. Then check the success by:
show tables;
mysql -u root -pThis logs you in as the root user (-u signifying which user you want to log in as) and -p signifies that you are logging in with a password, which you will be prompted for after you enter the command. The MySQL root password is set when you install MySQL server.
create database [nameOfDatabase];Don’t forget the ; at the end, or you’ll end up on a new line consisting of a > prompt waiting for more input. You can put the ; in then if you forgot to complete the command. An example of the above would be:
create database wikiDB;…which would create the database named wikiDB. You should see the following on a successful command:
Query OK, 1 row affected (0.04 sec)If that is all you had to do you can now exit MySQL by typing:
exit…and you’re done!
mysqladmin -u root -p password NEWPASSWORDEnter the current root password when prompted and replace NEWPASSWORD with the desired password. This should return you to the command prompt, and you can test whether it was successful by logging in:
mysql -u root -p