Mysql Workbench priveleges, data import - mysql

When I try to change the priveleges on a mysql db I get the following error:
Please make sure the used account has rights to the MySQL grant tables. Error executing 'DESCRIBE mysql.db'
Is this also why it will not let me import tables in from another DB? When i try I get the error:
Operation failed with exitcode 1
09:20:16 Restoring D:\design and photos\boo.com\db dump\070113.sql
Running: mysql.exe --defaults-extra-file="c:\users\darren\appdata\local\temp\tmpslubjs.cnf" --host=87.117.239.19 --user=boo8_yu52 --port=3306 --default-character-set=utf8 --comments < "D:\design and photos\boo.com\db dump\070113.sql"
ERROR 1044 (42000) at line 1: Access denied for user 'boo8_yu52'#'%' to database ' boo8_6652'
It does however let me create tables manually. Can't work it out at all.

make sure that the account you are using is granted with grant option
and the account should have permissions on mysql database in which the db grant table exits
or the best way is to assign the permission with the root account
see the link below may be useful for you
http://blog.loftninjas.org/2008/04/22/error-1044-42000-at-line-2-access-denied-for-user-root-to-database-db/

Related

Mysql console backup import fails in correct directory with correct password

I use Ubuntu server 16.04 (xenial) with Mysql 14.14 Distrib 5.7.20 (x86_64) with EditLine wrapper.
I have a Wordpress site /var/www/html/${domain}/ which I've duplicated with cp into /var/www/html/test/ and changed wp-config.php accordingly.
I have exported a DB backup of ${domain} this way:
mysqldump -u root -p"${rps}" "${domain}" > /var/www/html/test.sql
This test.sql file weighs 22mbs, just like a regular sql backup of the site, so the operation seems to be successful.
I've also logged into the mysql console and created an authorized, all-privileged DB user and instance, for the test site:
CREATE user "test"#"localhost" IDENTIFIED BY "${sps}";
CREATE database test;
GRANT ALL PRIVILEGES ON test.* TO test#localhost;
Note: rps and sps stand for "(mysql) root password" and "(mysql) site password". Echoing both show correct values.
I then exited back to the Ubuntu console.
So far so good, but here's the problem:
While in /var/www/html/ I tried to import my test.sql file into it's corresponding DB instance:
mysql -u test -p"${sps}" < test.sql
And yet, my import operation fails.
I also tried this import syntax:
mysql -u test -p"${sps}" test < test.sql
Both import operations failed with the exact same error:
ERROR 1045 (28000): Access denied for user 'test'#'localhost' (using
password: YES)
My question
Why would I be denied access when I seem to use the correct password?
I emphasis that I've double checked and ensured that ${sps} holds the correct password by echo ${sps}.
Update_1
Even though this session includes the main parts of the code, you can view the entire code here.
Update_2 --- milestone
It seems that the problem is due to the variable not being expanded when the user is being created:
CREATE user "test"#"localhost" IDENTIFIED BY "${sps}";
I've confirmed this when manually creating a user with a password. Passwords fromo variables just won't count.
The reason it happens is because the variable ${sps} didn't get expanded inside the Mysql shell; Mysql shell isn't bash and doesn't include this behavior of variable expansion (in this case, of the type variable substitution).
See more data and a way to cope with this here.

unable to truncate a table using remote login

I use remote login to connect to the database (residing on AWS). I'd like to truncate one of my tables. But this command does not seem to work on bash:
mysql --login-path=remote --database=marketing 'truncate table my_test_table'
I get the message
ERROR 1044 (42000): Access denied for user 'mdb_updater'#'%' to
database 'truncate table pedram_test_table'
mdb_updater is my username on the database.
This is when I can successfully run mysqlimport and mysqldump using the same credentials.
MySQL cli treats positional argument as database name, pass statement you want to run with --execute option:
mysql --login-path=remote --database=marketing --execute 'truncate table my_test_table'

Cannot import SQL file when the database name contains an underscore

I'm attempting to import an SQL file into a MySQL database using the following command;
mysql --user example -p --database example_database < example.sql
This returns the error:
ERROR 1044 (42000) at line 22: Access denied for user 'example'#'%' to database 'example'
Notice the database name has trimmed everything after the underscore. The connection details are definitely correct as I can connect to MySql using the following command:
mysql --user example -p --database example_database
Any ideas why this is happening?
A likely explanation for the observed behavior is that the example.sql file contains a statement:
USE example;
The error is thrown when that statement is being executed because user 'example'#'%' is not granted privileges on that database.
(I don't believe the --database option value is being trimmed right before an underscore character. The conjecture about the underscore in the database name is a red herring.)
Edited to add in comment below:
It looks like it's referring to the example.sql database you're importing into. Have you first granted all privileges to your 'example' user on that example.sql database? Something like
GRANT ALL PRIVILEGES ON example.* TO 'example'#'%' WITH GRANT OPTION;
Try putting `` around the database name with the _ in it
mysql --user example -p --database `example_database` < example.sql
This should allow you to import the whole name

MySQL Create View

I tried to create a view for the table VIEW in information_schema.
CREATE OR REPLACE VIEW Research as
select * from VIEWS;
But I'm getting an error like:
Error Code: 1044. Access denied for user 'root'#'localhost' to database 'information_schema'
What is the problem here? I can select other tables from the schema.
you should run mysql -u root -p in bash, not at the MySQL command-line. If you are in mysql, you can exit by typing exit.
NOTE: use 'quit' to exit the mysql,then you will be in bash

MYSQL restore command saying I'm trying to restore to a different database?

Hey guys I'm trying to restore a database called "hs" but MYSQL is saying, I'm trying to restore a database "mysql"
I've su root to get super user access,
[root#server init.d]# sudo mysql -u hs -p --database=hs < /home/hs/blankhsdb.sql
Enter password:
ERROR 1044 (42000) at line 1: Access denied for user 'hs'#'localhost' to database 'mysql'
Why could this be happening?
You interchange the variables there..you used 'hs' for user which is in your case, a database.
mysql -u #username# -p #database# < #dump_file#
Read this example syntax here..
http://www.techiecorner.com/31/how-to-restore-mysql-database-from-sql-dump-file/
Fixed it,
sudo mysql --database=hs < /path/to/filename.sql
maybe just a case of it getting confused as username and db are the same