I currently have access to only the views on a remote database, and I'm trying to copy the data of those views locally so that I can work faster. I've tried to use mysqldump to create a .sql file and load that, but it doesn't seem to work.
To get the remote db:
$ mysqldump --single-transaction -u username -p -h somesite.com -P 32000 db_name > mysql.sql
To copy to local:
$ mysql -u root -p mydatabase < mysql.sql
But I get an error
ERROR 1146 (42S02) at line 668: Table 'db_name.some_view' doesn't exist
My local database is completely empty except me creating an empty one using the command create database mydatabase; in the mysql shell.
Am I getting this problem because I can't use this method in the first place since I only have access to the views in the remote database?
Did you taken the data from the remote system correctly.If not try this command once you connect through remotely to database server,the command is
mysqldump -u username -h 192.168.X.X -P password --routines>xxxx.sql
It will ask the password of the database.Till now data is only in database server.From your local system use this command to take the data from database server,the command is
rsync -vaH username#192.168.X.X:/datalocation /yourlocation
Now the data is on your local system.Then after create one database in your system.
mysql
create database;
grant all privileges on databasename .*to databaseschema#'%' identified by 'password';
flush privileges;
I think this may help you,if not sorry bro.
Related
I just had to change [dedicated CentOs] servers at Godaddy.
After I uploaded my .sql database backup file to the site using FTP, I connected to my site using SSH.
After changing to super user using the su - command, i tried using the following code to restore my database:
[root#sXXX.XXX.XXX.XXX ~]# mysql -u alaskasl_destiny -p alaskasl_freakout < /home/alaskasl/backup/databases/alaskasl_freakout.sql
I get the following ERROR 1044 (42000): Access denied for user 'alaskasl_destiny'#'localhost' to database 'alaskasl_freakout'
I can't figure out what I am doing wrong. This command has always worked for me in the past
First and foremost, if alasas1... is your real username, I would replace it with 'username'. Never give that info out, especially on a public place like Stackoverflow.
That said, a few things to check
1. You need to know the root user's login credentials for this new mysql instance. If this is a new setup the user is root with no password, so you should be able to use the following command:
$ mysql -u root
Once you do get in to mysql, you will see a prompt similar to:
mysql>
at that prompt you can type
mysql> show databases;
and a list of databases will display. Does the database you expect to be in there in there?
if not, here is what you need to do:
mysql> CREATE DATABASE 'database_name';
mysql> CREATE USER 'username' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON *.database_name TO 'username';
mysql> exit
At this point what you did was create the database, create a user with a password in mysql, and granted access to that database for that user. Once you type exit, you should now be back at the command prompt.
Now you can run mysql -u username -p database_name < /path/to/sql_file.sql
I use this command to create .sql files of all tables in a huge mysql database:
mysqldump -h localhost --user=username -p --tab=/var/tmp database_name
The command above works perfectly but is prompting for the password.
Before i run this command i need to run:
GRANT FILE ON *.* TO 'username'#'%'
otherwise i get the error:
Got error: 1086: "File '/var/tmp/a_ab_text.txt' already exists" when executing 'SELECT INTO OUTFILE'
a_ab_text is the first table of the database.
Is there a way to get around this as I need to create a script that can be daily run as a cronjob.
To be clear a need a way to have the password in the script but typing the password after the --password '********' does not work.
And i need a way to overwrite the tables every day as we export all tables daily to a local server giving timestamp to the back-up file in order to have a dayly back-up version.
And of course i need a way to get around the command GRANT FILE ON *.* TO 'username'#'%' and restart the mysql server.
Thank you
I have a MySQL database existing on a remote server. I only have sql connection privilege. I don't have FTP access to the server, and I need to do a complete dump of the database. I have tried mysqldump, but the issue is that it is creating the output on the server and as I don't have FTP I can not get the output from the server.
How can I do a clean backup and get the dump in my local machine(of course, the backup should be restored in my local machine)?
You can specify the server name as an option to mysqldump:
mysqldump --host servername dbname > dbname.sql
mysqldump --host hostaddress -P portnumber -u username -ppassword dbname > dbname.sql
Normally the remote port of MySQL is 3306. Here is an example:
mysqldump --host 192.168.1.15 -P 3306 -u dev -pmjQ9Y mydb > mydb.sql
You can use the MySQL workbench http://www.mysql.com/products/workbench/, which can backup directly to a local folder through a user-friendly interface
mysqldump.exe locks tables by default, so other SQL actions are not possible during a dump. Without locking any tables, use the following syntax to backup a complete remote db and dump everything on your local machine:
mysqldump -u username -p --single-transaction --quick --lock-tables=false -h ipaddress myDB > backup.sql
Change username into your own username, change ipaddress into the remote ip address, and myDB to the actual database you want to backup. This will prompt you for your password. Once provided, the dump starts.
I use SQLyog for this where we can connect to the remote server and take a back up with this tool.
If the server admits PHP, you can upload and try Adminer. I like it as a PHPMyAdmin replacer, and you can create backups with it!
I'm self learning SQL. I've completed the SQLzoo course and wanted to get my hand dirty using a free Microsoft test database and MariaDB as client.
I've downloaded the database and saved it on the following path:
/usr/bin/northwind_mysql.sql
To access the database I've tried the following command but
gianluca#gianluca-Aspire-S3-391 ~ $ mysql -u gianluca -p -h localhost northwind_mysql
Enter password:
ERROR 1044 (42000): Access denied for user 'gianluca'#'localhost' to database 'northwind_mysql'
What I'm doing wrong?
Is there any clear Getting Started guide somewhere for people who don't have any experience with SQL?
I'm using it at work (MS SQL Server 2008), but I'm only querying the database with simple reading script. I would like to start learning more, for instance how to start it.
Thank you in advance.
I ran the following steps and connected successfully.
Verify connect as root
mysql -u root -p
mysql> show databases;
mysql> exit;
Download the Northwind database
Get it from here: http://code.google.com/p/northwindextended/downloads/detail?name=Northwind.MySQL5.sql
Set up the Northwind database as root
mysql -u root -p < Northwind.MySQL5.sql
Add gianluca as a user and grant permission to northwind
CREATE USER 'gianluca'#'localhost' IDENTIFIED BY 'whatevs';
GRANT ALL ON northwind.* TO 'gianluca'#'localhost';
FLUSH PRIVILEGES;
exit;
Connect as gianluca and access northwind tables
mysql -u gianluca -p
show databases;
use northwind;
show tables;
Notice that once you have created a username on localhost you don't have to specify it when connecting.
I'm trying to push my database to a remote mysql database hosted on ClearDB.
I'm using the command
mysql -u username#us-cdbr-east-*** -pmypwd dbname < mydb.sql
I'm getting the error
Access denied for user 'bbea98e4ba67c1#us-cdbr-east-**#localhost (using password YES)
Am i using the correct syntax ? I tried importing the same sql file to a local database and it happened smoothly.
DO i need to GRANT some proviledges to this remote database on heroku ? If yes then how should i do it ?
you should have privileges set on the database to be accessed from the remote host where you are trying to read in the dump. When creating access for a username you always specify a corresponding host. This could be % for any host... In that case you don't have to do anything. Sometimes it is set to a specific host, in which case you need to add a privilege for the same username but with a different host being the remote host.
Also you need the correct syntax would be:
mysql -u username -h us-cdbr-east-*** -pmypwd dbname < mydb.sql
notice the -h switch