I created a WordPress site offline and after finishing it I want to move it to a server. Moving the wordpress directory with all the files was easy. And I also exported my wp database with localhost/phpmyadmin to an sql-file. There are some servers which support phpmyadmin which would make the database import on the server easy. But how to do it with unix commands?
According to this site I have to create a database on the server first and then import the sql file.
$ mysql -u root -p -e 'create database salesdb1;'
$ mysql -u salesdb1 -p sales < sales.sql
I figured out that “-p” stands for password and I didn’t need it because there was no password. Before I do anything wrong I have a question – where to put my sql file on the server and how to import it?
$ mysql -u <my_unix_user> ...
Put the sql sump file in your
/tmp
directory or any other folder where your user has full rights on it.From unix comd line :
-alter the cmd and input your own values.
From inside the database:
create database
.user_name@'% - or an ip address'
Here you need to state the ip address of the app server, if it’s on the same machine as the database uselocalhost
if you want it to connect from any place use the wildcard `%’To add an user with no password follow here:
(i don’t recommend this – but to answer your question)
Next connect to the db :
To test you db connection :
-create and call a php with this content !
please have a look at the following from wordpress website