copy all tables from a database to another database in mysql - mysql

I'm using MySQL Workbench, I have different databases and I want to copy all the tables from those databases to a new database called newDB, I don't have access to the root account, but I have user and password for every database by separate, I've exported correctly all the tables using the Data Export Wizard within MySQL Workbench, but when I'm in the newDB tab and I try to import the tables from one of the other databases using the Data Import Wizard I'm receiving this error:
ERROR 1044 (42000): Access denied for user 'userNewDB'#'%' to database 'db1'
The error message is very clear, I'm under newDB tab in MySQL Workbench and is trying to import those tables from a different database that doesn't recognize that username, is there any way that I could do this using a query and passing as parameters the user and password for db1? Let's say that the user for db1 is userdb1 and the password is passdb1. Is that possible or it is mandatory to do this under the root account that I don't have access to...

Grant all privileges to the user first:
GRANT ALL PRIVILEGES ON *.* TO 'user'#'localhost' WITH GRANT OPTION;

Related

Mysql Mariadb user not able to access DB

I created a schema and granted its permission to a specific user:
GRANT ALL PRIVILEGES ON USED_CARS.* TO ANDREW#LOCALHOST;
The database is created with root user and then granted these permissions to another user. now when I swith to another account I can list the schema with SHOW SCHEMAS; query however cannot switch to that DB with use USED_CARS; query.
Following error pops up:
ERROR 1044 (42000): Access denied for user 'ANDREW'#'localhost' to database 'USED_CARS'
What am I missing here? Thanks for the help in advance.
Sometimes depending on the configuration of server, you can use localhost or the ip:127.0.0.1
Could you try with this ...
GRANT ALL PRIVILEGES ON USED_CARS.* TO 'ANDREW'#'%';

CREATE DATABASE using phpmyadmin in online server

I install phpMyAdmin on my subdomain for my clients to access their Databases, Because I can't give my Cpanel Login to them.
But my problem is when they need to create a new database, they can't do it from phpMyAdmin and they face this error
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY
'root';
And I try to create a DB using phpMyAdmin, login from cPanel but I had the same error.
No worry I can create and manage user and DB from cPanel, But the problem is I have to create a database myself when my client needs DBS.
So has I have an option for this, any type?
In your case, this error means the MySQL user does not have the required privilege to create a database. These are some options you could do:
Grant their user all privileges on all databases (not recommended):
GRANT ALL PRIVILEGES ON . TO 'sserver_sserver'#'localhost';
Create the database yourself and give their user all privileges on that specific database:
CREATE DATABASE my;
GRANT ALL PRIVILEGES ON my.* TO 'sserver_sserver'#'localhost';
Give their user all privileges to databases beginning with a certain prefix such as their business name which will allow them to create and work on as many databases as they need:
GRANT ALL PRIVILEGES ON 'businessname_%'.* TO 'sserver_sserver'#'localhost';

Access database outside of vagrant box as user

I'm using Homestead and have created multiple databases. I now wanted to use a new username/password combination for each database I create. I did it like this
CREATE DATABASE testdb CHARACTER SET utf8;
CREATE USER 'testuser'#'localhost' IDENTIFIED BY 'testpassword';
GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'#'localhost';
Now, when I access my vagrant box via vagrant ssh and then use this command
$ mysql -utestuser -ptestpassword
I can connect to the database. However, when trying to access the database from outside (like via a client (Sequel Pro)) I can't connect to the database with the created user.
I can, however, connect with my "base account" homestead:secret. With the homestead user I can access every database, however I wanted to use my newly created user. How would I achieve this?
The error that comes from Sequel Pro is
Access denied for user 'testuser'#'10.0.2.2' (using password: YES)
This is the db connection config
You must also grant the access to the outside user:
CREATE USER 'testuser'#'10.0.2.2' IDENTIFIED BY 'testpassword';
GRANT ALL PRIVILEGES ON testdb.* TO 'testuser'#'10.0.2.2';

How to change/alter the mysql database user

I have the mysql database user on server as rob and password something like rob123
And now i tried to create a database for user rob, so i logged in as
mysql -u rob -prob123
I can able to login successfully and when tried to create a database like below
create database hello;
i got below error
ERROR 1044 (42000): Access denied for user 'rob'#'%' to database 'hello'
So i logged in as default mysql user as root and logged in successfully
mysql -u root
Now i can able to create a database with create database hello; , but i need to change the user of this database 'hello' as rob and password as rob123.
So how to alter the user of the database ?
you need to create user and grant permissions:
use hello;
create user rob identified by 'rob';
grant all on rob.* to 'rob'#'%';
grant select on `mysql`.`proc` to 'rob'#'%';

1044 - Access denied for user 'user'#'localhost' to database 'db'

I tried a lot to import the sql script to create database and tables through phpmyadmin in the new site I hosted. But i'm getting the error,
1044 - Access denied for user 'user'#'localhost' to database 'db'
I tried to create a sample db directly : create database sampled; I'm getting the same access denied error.
I'm not able to grant privileges to the user also, i'm getting the same access denied error.
Following is the output of show grants command,
show grants;
GRANT USAGE ON . TO 'someuser'#'localhost' IDENTIFIED BY PASSWORD 'somepw'
GRANT ALL PRIVILEGES ON someuser\_%.* TO 'someuser'#'localhost'
Any help would be appreciated. thank you.
If you are using Godaddy then don't directly go to phpMyAdmin and run the sql command.
You have to go to MySQL® Databases section and create a database there.
Then create a user and give it the permission to access the database you just created.
Now you can go to phpMyAdmin and write your SQL commands.
Hope this helps
It is clear that the user someuser do not have proper privilege over the database db. You need to grant privileges for the user over the database to correct this issue.
If you do bot have administrative rights contact your admin for granting privileges to someuser on that db
For me the problem is I'm not having permissions to Create new Databasename or even Modify the name of the Database. You can contact your admin to avail privileges or if you want to quickly import the .sql file... then you can open the .sql file with text editor and find the following line:
CREATE DATABASE IF NOT EXISTS `enter the existing db name` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `enter the existing db name`;
After that try to import the .sql file...now you can successfully import all the tables!
This error can be avoided in the beginning when creating the user account. Following commands must be used to create user account having all the PRIVILEDGES.
CREATE USER 'demouser'#'localhost' IDENTIFIED WITH mysql_native_password BY '***';
GRANT ALL PRIVILEGES ON *.* TO 'demouser'#'localhost' WITH GRANT OPTION;
ALTER USER 'demouser'#'localhost' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
CREATE DATABASE IF NOT EXISTS 'demouser';
GRANT ALL PRIVILEGES ON `demouser`.* TO 'demouser'#'localhost';
Must Ensure that your User_Name, Password and Database name are correct.
If you are Deal with database 'sampled' then type 'sampled' in query instead of 'db' also must ensure that you don't have to use quota(') in Statement.
you have not exported database from localhost or from web server correctly follow these steps go to localhost database click export tab than select 'Custom - display all possible options 'check box few options will open in section 'output' change compression none to zipped and now click go button at bottom it will properly export your database you can now import to hosting or anywhere you want with no errors
I had the same problem i solve it buy change the GRANTEE and made the user he can do all the operation in PhpMyAdmin ,follow the steps :
Enter to mysql in root permission but :
sudo mysql
Enter the password, and type this :
SELECT * FROM information_schema.user_privileges;
And see the user in IS_GRANTABLE is he yes or no.
If he yes then see the PRIVILEGE_TYPE what it might it be just tow operation if it's true add the last operations.
and see this link to change IS_GRANTABLE from no to yes.
I wish this could help you.
I started getting this error message for no reason at all. Solved by using MySQL and the Server menu option; Selected my bitnami_wordpress schema; selected the bn_wordpress user; then picked the Administrative Roles tab and granted access to this user. I had to do this to all of the users that the access was removed from.