August 21, 201115 yr 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
August 21, 201115 yr 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
August 21, 201115 yr 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
August 21, 201115 yr 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; } }
August 21, 201115 yr 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
August 25, 201115 yr 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...
August 25, 201115 yr 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
August 26, 201115 yr 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 August 26, 201115 yr by clf1605
August 26, 201115 yr 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?
August 26, 201115 yr Author Thanks guys for the help, I'm going to move it back to the original host, where at least it worked!
Create an account or sign in to comment