I have been searching for a while to find a good answer to my problem.
I have a new server where I would like to run a script in .php which uses a database to store some data. What I have done so far is:
Place the .php file in the server with the help of Putty.
Create a database in phpmyadmin, export it and place it in the same folder of my project in putty.
Run php5 crawl.php > logfile.log 2&>1&
but it doesn't update the database.
I am little bit confused with the steps I have to make in order to make it work. I have been reading also this article http://www.aspkin.com/using-putty-to-import-a-database/ but when I run the
mysql -u dbusername -p databasename < backupname.sql
I get this error:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Any idea what I might be doing wrong?
if it's a local machine you may not have a password on it for root - so remove the -p tag.
Otherwise you want to specify the password in there with it, without a space, like so:
mysql -u dbusername -pYourPassword databasename < backupname.sql
zcat /path/to/file.sql.gz | mysql -uroot -p your_database
Related
I am trying to restore database from db.sql dump
I have installed mysql (both client and server), when I have installed server I defined password for root user
and I am trying to restore DB with such command
nnn#nnn:~/prj/myprj$mysql -user=root -password=qwerty <db.sql
But I get the following error
ERROR 1045 (28000): Access denied for user 'ser=root'#'localhost' (using password: YES)
I have just create this password so it could not be wrong. Perhaps something else wrong in syntax? (I am using ubuntu by the way)
You need double dashes in front of long option names like --user, with singe dash it is taken as short option -u and the rest is taken as user name ser=root
So it is either
mysql --user=root --password=qwerty db_name < db.sql
or with short options
mysql -uroot -pqwerty db_name < db.sql
Can’t figure this out, and all of my searching hasn’t helped.
When I login to mysql and I enter
$ mysql -u database_user -p
Enter password: ******* #here I enter my_password
this works. the next thing I see is the mysql> command prompt. However, if I enter
$ mysql -u database_user -pmy_password
or
$ mysql -u database_user --password=my_password
Both of which, according to the documentation, should be allow me access. I get the access denied response.
ERROR 1045 (28000): Access denied for user 'database_user'#'localhost' (using password: YES)
I've tried a lot of variations specifying database or host:
$ mysql -u database_user -pmy_password -d database_xxx -h localhost
But I keep getting the Access Denied error.
I want to pass my password as a command line argument so I can write some scripts to automate some tasks.
Has anyone else run into this issue or know why if I'm prompted for a password, I'm good, but if I pass it in as an argument, I cannot login.
Your password doesn't happen to have a '$' in it, like pa$$word? Or another character that might mean something to the shell?
In that case you will need to enclose your password with single quotes '
$ mysql -u database_user -p'my_password'
While I'm not sure exactly why you are having that problem, I strongly recommend against passing the password on the command line. The best practice is put the password in a secure file and use the --defaults-extra-file option. That way the password is not displayed in plaintext in the process table.
For your example, you could create a /etc/mysql_login.cnf file and permission it such that only you can read it, then put this in the file:
[client]
user=database_user
password=my_password
Then call the mysql cli like this:
mysql --defaults-extra-file=/etc/mysql_login.cnf
I am trying to connect Zapier to my Database. Zapier has very limited support for this and seem to be going round in circles.
I need to GRANT SELECT to a user on my database with this code;
GRANT SELECT ON my-database-here.my-table-here TO 'user-here'#'ip-address-here' IDENTIFIED BY 'my-password-here';
The error i receive is;
#1044 - Access denied for user 'xxx'#'localhost' to database 'xxxx'
The user has ALL PRIVILEGES but can't seem to get it to work. Any help here could be greatly received.
Thanks
You may need to set up a root account for your MySQL database:
In the terminal type:mysqladmin -u root password 'root password goes here'
And then to invoke the MySQL client:mysql -h localhost -u root -p
you have 2 issues:
1 => mysql -uroot -p should be typed in bash (also known as your terminal) not in MySQL
command-line. You fix this error by typing.
exit
in your MySQL command-line. Now you are back in your bash/terminal command-line.
You have a syntax error:
mysql -uroot -p;
the semicolon in front of -p needs to go. The correct syntax is:
mysql -uroot -p
type the correct syntax in your bash commandline. Enter a password if you have one set up; else just hit the enter button. You should get a response that is similar to this:
I am logged into an AWS instance and trying to copy a mysql database to a .sql file. I am using the command:
mysqldump -u [username] -p [databasename] > [database].sql
Then entering the password and the following message comes up.
"mysqldump: Got error: 1045: Access denied for user '[username]'#'localhost' (using password: YES) when trying to connect."
I can login directly to mysql using the same credentials as above, but still get the same error.
I have tried a bunch of different ways for the command above, but it seems to be an issue with permissions or something similar. The user does have all privileges for the database when looking in phpmyadmin so I am not sure what is wrong? Any suggestions? Thanks
This works for me:
mysqldump -uroot -pxxxx dbname > dump.sql
or you can specify the host:
mysqldump -h localhost.localdomain -uroot -pxxxx dbname > dump.sql
Check to make sure you don't have different instances of mysql running
Thank you all for your input! It got me thinking about what else it could possibly be. I then tried using the -h parameter as well, which wouldn't work with "localhost". It finally worked when I used the Private IP Address for the AWS instance.
mysqldump -h [PrivateIPAdress] -u [UserName] -p [DatabaseName] > [Database].sql
mysqldump -u [username] -p
ENTER YOUR PASSWORD
USE [databasename]
SOURCE /path/to/[database].sql
I am not sure, but worth a try because you said you are able to login into that machine.
I exported all databases of a MySQL server by:
mysqldump -u root -p --all-databases > /tmp/dbs.sql
Then I copied the file (by scp) on another server, which has the same MySQL version, and imported it with:
mysql -u root -p < dbs.sql
I can access to MySQL only as root. With other users, I obtain:
~$ mysql -u jag -p
Enter password:
ERROR 1045 (28000): Access denied for user 'jag'#'localhost' (using password: YES)
However, selecting all users in mysql.user table, I can see that all user accounts where imported. So, how can I overcome this problem, without resetting all user passwords?
You need to specify username and password, you can try this:
mysql -u USERNAME -pPASSWORD -h HOSTNAMEORIP DATABASENAME
Note that there is no space between -p parameter and password!
You can check this: http://dev.mysql.com/doc/refman/5.0/en/connecting.html
After following all the similar answers for this issue, I've solved it in CentOS with this:
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
please make sure to grant privileges to that user u want to restore with, in this case 'jag'