Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Transferring MySQL database - Rename required

Featured Replies

Hi Everyone

 

I hope you can advise me before I cause catastrophic website failure here!

 

I am moving my website from one server to another.

 

But the new host is imposing 12 character limits on MySQL database name and username. Unfortunately the web designer created both with 22 characters!

 

I'm fairly sure I can't just rename them and expect the site to work, but will I have to go into every page of code and find every reference to the database and change the details, or is there an easier way? (perhaps a "find and replace" or a "if you find reference to X Old database, redirect to Y New database" instruction I could add to the root somehow)

 

Apologies if it's a stupid question.

 

Thanks

C

Hi Everyone

 

I hope you can advise me before I cause catastrophic website failure here!

 

I am moving my website from one server to another.

 

But the new host is imposing 12 character limits on MySQL database name and username. Unfortunately the web designer created both with 22 characters!

 

I'm fairly sure I can't just rename them and expect the site to work, but will I have to go into every page of code and find every reference to the database and change the details, or is there an easier way? (perhaps a "find and replace" or a "if you find reference to X Old database, redirect to Y New database" instruction I could add to the root somehow)

 

Apologies if it's a stupid question.

 

Thanks

C

 

well first of all, if your talking about database details which you connect to the database with through your php file, this should only be written on one of your php files, usually people put the mysql connect in a file called config.php and include the config into each file, so when the username and pass does change, they dont have to change it in every file, so looks like your going to have to go through every file, it cant take long

You could of course use something like http://www.wingrep.com/ to search and replace all instances of the username if you download the files locally, then upload them again, should the case be that you have connection details on every single page. That said, you would be better off replacing the connection details with an include, so that you can configure them in one place should you need to change them again. As for the "redirect" question, that isn't possible I'm afraid

  • Author

well first of all, if your talking about database details which you connect to the database with through your php file, this should only be written on one of your php files, usually people put the mysql connect in a file called config.php and include the config into each file, so when the username and pass does change, they dont have to change it in every file, so looks like your going to have to go through every file, it cant take long

 

 

thank you - i think i may have found it - does it look like this?

 

function DBConnect()

{

$this->host = 'localhost';

$this->user = 'xxxxxxxx_xxxx';

$this->password = 'xxxxxx';

$this->database = 'xxxxxxxx_xxxxxxxxx';

$this->status=false;

 

/*$this->host = 'localhost';

$this->user = 'root';

$this->password = '';

$this->database = 'xxxxxx';

$this->status=false;*/

}

 

// To Open the connection

function OpenConnection()

{

if($this->status==false)

{

$this->host = 'localhost';

$this->user = 'xxxxxxxx_xxxx';

$this->password = 'xxxxxx';

$this->database = 'xxxxxxxx_xxxxxxxxx';

$this->conn=@mysql_connect($this->host,$this->user,$this->password) or $this->ErrorHandler();

 

/*********Actives database for current use*****************/

mysql_select_db($this->database,$this->conn) or $this->ErrorHandler();

$this->status=true;

 

}

 

}

  • Author

You could of course use something like http://www.wingrep.com/ to search and replace all instances of the username if you download the files locally, then upload them again, should the case be that you have connection details on every single page. That said, you would be better off replacing the connection details with an include, so that you can configure them in one place should you need to change them again. As for the "redirect" question, that isn't possible I'm afraid

 

Ok thank you, very useful -

I have 4 interlinked sites, which were built separately (but run together) - they started as folders of the main site, but I now have domains for the separate parts - so I intend to split out all the files and mirror the database for the shared elements.

So I may be able to use this to replace the "direct to x folder" with the root url.

I'm going to have to be careful (especially as a novice) but it's quite formulaic, so it should be OK!

Thanks again

C

  • Author

Yup, changing those should fix it if that config is used by your pages

 

I can't actually find a file called config.php - I thought that the file whose code I posted above was the one, as it is in the includes folder and contains the db name, username and password of the previous db.

 

All the databases are loaded onto the new server (except I have just found one called information_schema - is that a default dbase that defines structure, and therefore required?

 

My site now has no content, I can see the bare bones, but no content.

I also have an admin panel for which I am entering the correct details and I cannot log-in (would this be related to the database?)

 

Do you have any ideas?

Sorry I know this is a bit vague...

I can't actually find a file called config.php - I thought that the file whose code I posted above was the one, as it is in the includes folder and contains the db name, username and password of the previous db.

 

All the databases are loaded onto the new server (except I have just found one called information_schema - is that a default dbase that defines structure, and therefore required?

 

My site now has no content, I can see the bare bones, but no content.

I also have an admin panel for which I am entering the correct details and I cannot log-in (would this be related to the database?)

 

Do you have any ideas?

Sorry I know this is a bit vague...

 

Reason you cant login is because its not getting to the database, in theory you should have some kind of error message to show if this is the case

 

There doesnt HAVE to be a file called config.php it could be called dfa897n30.php for any odd reason, although it is likely to be called config.php or connect.php or database.php something along them lines,

 

as obvious, this file will be being included into the main file thats running so the mysql queries etc can be ran, so look in the main files or functions file for something like require_once(""); or require(""); or include(""); and so on, obviously a file name will be between the quote marks, check all the files thats being included, if you change the details accordingly anyway to the new details then it should work anyway which is what i dont get :rolleyes:

  • Author

Hi Gary

I did actually find via several "include" links (header.php, functions.php, dbfiler.php) reference to the database logins only in the file from which I took the code posted earlier in the post.

I changed the code names and passwords in that file, but it's still not working.

Could it be something to do with the database configuration settings being different between my old host and new host?

(character set and collation system variables)

 

I also have this message on my new server phpAdmin page - is this significant? -

Your PHP MySQL library version 4.1.22 differs from your MySQL server version 5.0.77. This may cause unpredictable behavior.

 

Oh and I now also have an issue with the existing SSL certificate not being transferrable to the new host - they say it'll cost me £85 to buy a new one!

If I'd got the renaming of the databases right in the previous steps, could this SSL issue be causing the problem? I don't want to be paying £85 and then it still doesn't fix the issue!

 

Thanks

Claire

Edited by clf1605

Hi Gary

I did actually find via several "include" links (header.php, functions.php, dbfiler.php) reference to the database logins only in the file from which I took the code posted earlier in the post.

I changed the code names and passwords in that file, but it's still not working.

Could it be something to do with the database configuration settings being different between my old host and new host?

(character set and collation system variables)

 

I also have this message on my new server phpAdmin page - is this significant? -

 

okay yes, erm repost the whole of the script with your db stuff on like where it connects to the database and ill add error statements on for you so we can tell whats wrong

 

i dont know about the char set and collation sys variables,

 

and that message on the new server page isnt the problem i wouldnt have thought, maybe someone else knows different?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.