How to move a wordpress installation from xampp localhost to linux server?

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.

Read More
$ 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> ... 

Related posts

Leave a Reply

2 comments

  1. 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.

     unix cmd line:> mysql -u root -p <passwrd> -e 'create database db_name; use db_name; source /tmp/dump_file.sql; grant all on db_name.* to user_name@'% - or an ip address' identified by 'password';  flush privileges;
    

    From inside the database:

    unix cmd line:> mysql -u root -p <passwrd>
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 58208
    Server version: 5.6.10 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    create database db_name;
    use db_name;
    source /tmp/dump_file.sql --full path to the dump file
    grant all on db_name.* to user_name@'% - or an ip address' identified by 'password';
    flush privileges;
    
    • make sure the db users has privileges to create database.
    • the 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 use localhost 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)

    unix cmd line:>mysql -uroot -p passwd -e 'grant all on *.* to test123@'%' identified by ''; flush privileges;
    

    Next connect to the db :

    [root@fgv180b ~]# mysql -utest123  
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 60722
    Server version: 5.6.10 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql>
    

    To test you db connection :
    -create and call a php with this content !

    <?php
    $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    if (!$link) {
        die('Could not connect: ' . mysql_error());
    }
    echo 'Connected successfully';
    mysql_close($link);
    ?>