Non-coder here, please advise as newbie. I have a MySQL DB on my ISP's server that provides data for a web site. I want to set up a db on my localhost that I can use for local development. The DBs don't need to be linked, nor do they need to remain synchronized. I just need to start with a current copy of the ISP version.
I have used PHPMyAdmin on ISP to download what I think is a dump file. the file, [mydbname].sql shows the schema and all the data. I just can't figure out how to import it in MySQL Workbench on my local PC.
Using the MySQL Workbench Data Import tab, if I execute "Import from Dump Project Folder" where the .sql file is located, I get "There were no dump files in the selected folder."
If I select "Import from Self-Contained File" and select my ***.sql file, I get "ERROR 1142 (42000) at line 31: CREATE command denied to user 'root'#'localhost' for table 'account' Operation failed with exitcode 1"
I've attempted to give 'root'#'localhost' all privileges.
I'm guessing there's an issue with privileges. If there's another way to do this, I'd be thrilled to know it. Many thanks!
If what you have is a sql dump file then try this on the CLI:
mysql -h hostname -u user --password=password databasename < filename
Assuming of course that has the right privileges.
Non-coder here, please advise as newbie.
In that case, download heidisql : https://www.heidisql.com/
It also makes copying tables and database from server to server very easy.
Apart from that: there is most likely something wrong with your privileges. But you might have made that worse by trying to give privileges to root. The root user can already do everything. So maybe also have a look at this post : How can I restore the MySQL root user’s full privileges?
Related
I tried using the mysql pump to create a backup of my MySQL database. When I tried to restore the backup to another server I am getting the error mentioned in the title. I know that question with this error has been asked before but all answers state that I need to delete the definer clause from the .sql backup file. However, I do not have a definer word at all in my backup file because I backed up my database doing:
mysqlpump --skip-definer -u root -p testempty > c:\users\admin\documents\dumps\backup.sql
I searched trough the backup file and there is absolutely no definers at all.
However, the problem is that I am trying to backup and restore to a different database name and my sql contains database1.tableName syntax. I am trying to restore to database2
That might be the reason for the problem. I know that if I was using mysqldump instead of mysql pump I could do:
mysqldump -u root -p testempty > c:\users\admin\documents\dumps\backup.sql
which exports without database name
but mysqldump does not provide skip definer option :(
Why is it such a nightmare to backup and restore mysql database and so easy to do it in MSSQL database? I am trying to streamline my backup and restore process and there are roadblocks everywhere.
I downloaded the database, edited it with notepad++ and after that I deleted "Definer = your username # local host" and it worked for me.
I am importing a sql file to database using command prompt.But getting an error of Access denied. Details:
user: staging
host : %
It works with the following details:
user : staginguser
host: localhost
Import command:
mysql -u staging -p dbname < filename.sql
Can anyone tell me how to import a file for user with host % ?
Thanks in advance
First, and only for clarity purposes, you may wish to put the dbname just after the MySQL command. Second, you may wish to check if the contents of the file has references to the source database name (something like .) and the old db name differs from the new. Third, check that user staging has access to the db and if yes, check that it has the required permissions to perform whatever is contained in the file.
After you have done all the above, post an update to your question with all the details.
By the way, if you are using % as the host, it means that the user must have access from any host. Does he/she?
I asked this question 1 hour ago:
How can I transfer my data from one database(000webhosting.com) to another(shatellhost.com)? note: I use 000webhosting.com free hosting service and I can't create full backup. my data is phpfox social networking.
No one answered so I did this:
I transfered (download) whole data in public-html in 000webhosting.com to my computer and then uploded whole that to public-html of my new host in shotellhost.com, then when i try to open my site: www.ibiology.ir this appears:
Cannot connect to the database:
Can't connect to MySQL server on 'mysql5.000webhost.com' (4)
How can i change MySQL address to new MySQL?
Do a mysqldump and then import the SQL into your new database.
backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
This error appears to be due to the configuration file of your PHP code, the connection information did not changed properly when you change the host.
First thing to do is make sure that you have change your database. Because of the security reason, most hosting service does not allow connecting to there mysql server from another location. There for, you connect to the mysql5.000webhost.com from another server.
Second, review the code to find out which file containing the database connection information, which usually includes: database hostname, database username, database password, database name. If you use an PHP framework, check the documentation.
In general, this is what I usually do when moving a site to another host:
Open the PHPMyAdmin in my old host control panel
Export the full data of the current database. I usually check DROP TABLE/DROP VIEW option.
Save the exported sql file to my local drive
Open the control panel of my new host
Finding the MySQL configuration option. You may find the MySQL host name here, usualy is localhost (yes, 000webhost is a special case when not use this default host name).
Create the database and the user if necessary.
Write the database hostname, database username, database password, database name information properly into your php configuration file of your source code.
Open the PHPMyAdmin in the control panel of the new host, go to my database (just created) and import the previous sql file.
If everything works well, your code may work.
I am trying to learn PHP and MySQL and while I reached a chapter on MySQL I was asked to create a database using this command:
CREATE DATABASE publications;
After I typed it in the mysql console I got this error:
ERROR 1044(42000):Access denied for user ''#localhost' to database 'root'
I am already logged in to my administrator account so I think the privileges should't be a problem.I have installed with the XAMPP package.
How can this be solved?
It could be possible that you upgraded your version of EasyPHP or you did something to disable the root password. If that is the case, you should try reestablishing a password for root. Had the same problem and that's how I solved it.
Go to http://localhost/xampp/ and set the appropriate passwords (in Security tab). If you use mysql client program, make sure you call it with appropriate credentials: mysql -u <username> -p <password>. Username will mostly be root until you create some new accounts.
Then I suggest you use phpMyAdmin for experimenting with MySQL (it should be at http://localhost/phpmyadmin/ )
This is getting a little confused - let me try to answer this.
Mysqladmin is a command line client for administering your mysql database system - you normally don't need to run it once you have mysql working. The shell command line interface to the mysql server is mysql. (If you don't know how to run a shell command line, that's another problem. Also, if you're on Windows, say so, since that has its own challenges.) The arguments are:
mysql -u username -ppassword databasename
if you are running this command on the same server as mysql. Note the lack of space after the -p - that is important.
So, type the above line to invoke the command line interface to mysql. Then you can type your mysql commands. Things like show tables, desc tablename, etc., will work. That is they will work unless you have an authentication problem. But you will know you have an authentication problem because when you tried to run mysql as above, it will fail with some error, like "Access denied for user 'abc'#'localhost' (using password: YES)". This is a nice descriptive error message that points you exactly where the problem is.
Does that help?
You can go back to using xampp or anything else once you've made sure that you know the right parameters by checking with the command line. (Always check with the command line when strangeness happens - it's so much easier than trying to debug through other interfaces.)
Im trying to create my own database with MySQL Workbench and run some queries on it. I have MySQL server 5.1 running and can enter queries in the command line tool to ask for version number and such.
But how do I get the server to host the database that I created in Workbench? When I enter "use MijnDatabase" or "-u root#localhost -p MijnDatabase" it says the database cannot be found. This makes sense, "MijnDatabase" the database file name and it's not connected to the server in any way (also tried with "mydb" wich is the db name I see inside Workbench).
Anyway I'm missing the link between MySQL server and hosting an actual database file.
When you create a database use only lower case letters and use underscore to separate words:
create database my_database;
use my_database;
show tables;
etc...
To connect to your database use:
mysql -u root -p
enter your password then
use my_database;
show tables;
etc...
I have not used MySQL Workbench but the command line and phpMyAdmin. I suggest you start using the command line to learn a little bit MySQL, then use a GUI tool. However the command line is your best teacher.
Have a look in the reference doc: http://dev.mysql.com/doc/refman/5.1/en/create-database.html
. Lean how to create a user and grant him permission on the database.