how to change the username of a mysql database? - mysql

This may be a basic problem in the database world but I don't speak 'databaseian' fluently.
I am transferring a website from one hosting service to another; from server A to server B. Server B offers the service of transfer but I would like to do it myself. The website is based on WordPress.
My strategy is:
to copy all the files from one server (A) to the other one (B) (done).
to export the mysql database from server A into a .sql file (done).
import the .sql file into a new database in server B so now Wordpress can talk to MySql (here is the problem).
The hosting service in server B provides the phpMyAdmin where I can import a .sql file ,the problem is that the database in server A was using a particular username (defined by them) and server B has another one (which I cannot change).
Is there a way of editing the .sql file in order to change (add) the username to the one in server B so I can import it smoothly?
Note: I have the password for the .sql database and username as well.
Update: The error shown by phpMyadmin when trying to import the .sql file is:
#1044 - Access denied for user 'userServerB'#'localhost' to database 'db-server-A'
Many Thanks
UPDATE: Everything is working now. Apparently the .sql file had a line that was trying to create a new database itself. I got rid of this line and just used a pre-created database using all the rest of the .sql file and voila. Particular thanks to #daking963

The database username/password is not part of the dumped database sql. It is part of the connection authentication details. You used one username/password to connect to server A, and a different one to connect to server B. The sql file is independent of this.
So, first just log in to phpMyAdmin on server B using the username/password they provided. Then, import the sql by following these steps:
1. Select the database you want to import into (or create a new one).
2. Click on SQL tab at the top.
3. Click "browse" next to the file upload box and select your sql file.
4. Click go to start the import.
UPDATE: Regarding your update showing the error message. It is trying to import the sql into a database named db-server-A on server B. Open the sql file in a text editor, and replace all instances of db-server-A with the name of your database on server B. Then save and repeat the steps above.

Can you change the access details in the wp config file for the new server:
wp-config.php

Related

How to copy table from a database on SERVER 1 to another database on SERVER 2 using phpMyAdmin?

I have a database named db_x on server X (running WHM) and another database named db_y on server Y. I connected to server X via SSH made some changes to the phpmyadmin configurations to allow it to connect to db_y via phpmyadmin on server X via cPanel. Now, I want to move all the tables of the db_x on server_X to another database(db_y) which is on different server(yy.yy.yy.yy) by using phpMyAdmin from server_X.
Is there any way to do so? Please help me.
Edit: The table is over 3 GB, so export/import won't work.
due to the size of your database you will not be able to succeed with phpmyadmin.
Try use the SSH.
Upload the database to the new server "old_database.sql".
Considering that the database already existis on the new server, use the command below:
# mysql new_database < old_database.sql
This command will import your sql file into the new database.
If you don't have the old_database.sql file, you can also obtain it with command in old server
# mysqldump mydatabase > old_database.sql
This command will generate an SQL file from your database.
Ther will be an option export in db_x export it and in db_y click import
and chose downloaded file wich was exported and click run.

phpmyadmin - localhost.sql import - #1046 - No database selected

I have an old backup of some localhost databases (localhost.sql), which needs to be imported into PhPMyAdmin on a Windows 7 machine with XAMPP installed.
When I try to import localhost.sql (containing multiple databases) in PhPMyAdmin, I get the following error:
#1046 - No database selected
With a single database, you would simply create a new database with the same name and import to that. As this is an old backup, I am not able to recreate the export and I also donĀ“t know the database names that are inside localhost.sql.
Is there a way to recover this?
You have two possibilities to do this :
Create all the databases by hand in phpMyAdmin. Split your .sql file so that each file corresponds to a database. And finally you import each file in the correct database.
Edit your localhost.sql file and add the commands to create the databases ("CREATE DATABASE ...") in the right place. Then you import all at once.

exporting drupal database from devlopement box to drupal database (new from install ) in cpanel - duplicate data

I am new to phpMyAdmin, and cPanel, I have developed a site in my local box, and now I need to transfer the site into cpanel in the server where the site will be there in test mode.
I have installed drupal in cpanel successfully, and now I want to take my drupal database from my local box to the database in Cpanel .
so the export file I generated, includes all the insert statements for some of the tables that already have those data in cpanel, so obviously I get the duplicate primary key error.
how can I import drupal database data (my local box -development) into the new drupal database( set up when installed drupal in cpanel) without dealing with duplicate data which is for the default tables/data
I am using phpMyAdmin in both my local (dev) box and server side
I appreciate any one 's help
I would create a new empty DB on the host, import your dev db, then change the db name in the settings.php file to point to the new DB.

Downgrade mdf file from 661 to 655

I created and database in sql server 2008. I took the mdf and ldf files to Visual Studio 2010 project and tried to connect to that db with entity-framework. and got the following message:
I cannot reinstall or upgrade the software on the specific computer.
So is there any way to downgrade the version of the mdf and ldf files?
No, you cannot downgrade, you will need to move the schema and data another way if you can't install the right version. This recent question is essentially the same:
Failure attaching SQL Server 2008 database to SQL Server 2005
Essentially you can use the Generate Scripts tool or the Export Data wizard to get your destination database to look like the source. You will not be able attach your MDF file.
And this blog post shows some 3rd party tools that can help with this:
http://bertrandaaron.wordpress.com/2012/04/20/re-blog-the-cost-of-reinventing-the-wheel/
No, you need to install the same or newer version of SqlServer.
There is no known way to downgrade an MDF file.
Links
http://blog.sqlauthority.com/2008/10/16/sql-server-downgrade-database-to-previous-version/
Perhaps, if you have access to the SqlServer 2008, you could use the command
"Tasks" -> "Create Scripts" to start the wizard to create a script with schema and data.
On the options page there is the button 'Advanced' where you can select the syntax version of SqlServer
The way that I found that worked was to export the database and stored procedures from the original database. Then upload them into the second database(second computer).
Firstly export the DB content (data) - I used SQL server export data wizard. on the database you wish to export from right click then choose tasks, then export data. Follow the instructions and save in whichever format is best for you - I used excel for the data.
then to export the stored procedures rightclick the database name again. choose tasks and this time choose generate scripts. again follow the instructions of the wizard.
To import the data simply go to the second computer and right click the database you wish to import the data into. again tasks > import data. Follow the instructions to import all of the data from the database.
Finally to import the stored procedures, I opened up a new stored procedures command and dragged and dropped the script file that I had previously saved them in and dropped it into this window. The new stored procedure window filled with the entire list of my stored procedures.
Finally change the name of the database name that will be used by the SP ( if this is different from the original DB name). (This is the first line USE [DBName].
then simply execute and the SP's will be fully restored.
This has helped me get my entire database up and running again very quickly.
Hope this helps.
U can open it on another pic and then publish it to sql script with or without data then create database on target PC using sqlcmd or anything. Then run sql script...

How do I move data in my production server to a database on my test server : MYSQL

I have data in a table A on my prod server. I want to move the data in it into table A (same name) on my test server.
What is the simple way to do this without exporting the data into some file and then inserting into my test table?
Thanks. I Looked around S/O and couldnt find a satisfactory answer.
If you have a tool like SqlYog, it's pretty simple with a couple of clicks of the mouse, otherwise you cannot do it because a query works in the context of a db connection, and for different servers you need different connections.
If you have phpmyadmin installed on both servers do the follwing
go to the table in phpmyadmin on your prod server
click export and export as .sql
go to the table in phpmyadmin on your test server
click import and upload the .sql file
If your database is more than 8 mb you can always compress it