Database migration issues - Error #1046 No database selected

i need to get my clients website online and have been able to figure everything out except of course the most crucial part which is the database upload. i can't figure out what i'm doing wrong since every tutorial and forum i've been on has basically told me to do the same things and still i get errors. i'm missing a crucial point that must be assumed. the test i've made was to locally move my database by simply copying my local site and renaming the database and adjusting my config.php file accordingly. after that i figured my database was set for upload but after uploading i get the error: #1046 = No database selected.

how can there be no database selected?

Topic localhost migration production database Wordpress

Category Web


If you did a db export from phpMyAdmin and are trying to run the big SQL statement, you may need to add a line to that file telling MySQL what database to use, as phpMyAdmin doesn't do this by default.

before any of the inserts, put the line

use my_database;

Make sure to substitute the correct name for my_database, and don't forget the semicolon. Then try to run the statement. Hope this helps!


99.99% chance that you configure wordpress with wrong database details.

make sure you are using correct database details in wp-config.php file

/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

some possibilities are listed here based on my experience:

  1. May be you didn't use any prefix with database name or user name, which are added by default when we create them on online server.

  2. May be using wrong server details. mostly we use localhost but sometimes database server may be use from outside.

  3. May be user not assign to database.

Hope this helps you. All the best ;)

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.