Mysql: new user access denied to database - mysql

I'm using Mysql 5.5. I logged in mysql by root and created a new user.
Then I logged in using
mysql -u newuser -p
Then in mysql I entered
GRANT ALL PRIVILEGES ON db1.tablename TO 'newuser'#'localhost';
in order to access to the databases.
But there is an error message:
ERROR 1142 (42000): SELECT,INSERT,UP command denied to user 'newuser'#'localhost' for table 'tablename'
I even tried other commands such as GRANT CREATE or GRANT DROP, the same error keep showing.
ERROR 1142 (42000): CREATE,GRANT command denied to user 'newuser'#'localhost' for table 'tablename'
Can someone please help?

You logged into MySQL as root and created the new user, but you need to grant the permissions to the new user as well while logged in as root. Then you'll be able to login as newuser and execute statements.

Related

unable to create database in mysql or via ssh

I m trying to create new database through mysql or ssh but on both m getting error
mysql : CREATE DATABASE porto;
Error : Access denied for user 'root'#'localhost' to database 'porto' on ssh : ERROR 1044 (42000): Access denied for user 'root'#'localhost' to database 'porto'
mysql> CREATE USER 'testuser'#'localhost' IDENTIFIED BY 'ecomaddon#42';
ERROR 1227 (42000): Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation
mysql> SELECT User,Host From mysql.user;
ERROR 1142 (42000): SELECT command denied to user 'root'#'localhost' for table 'user'
Its problem of privilege but don't know how give root user all privilege ai had try all methods but got nothing.
You can try to access as root
mysql -h 127.0.0.1 -P 3306 -u root -p
If it still does not work follow this guide
https://www.a2hosting.com/kb/developer-corner/mysql/managing-mysql-databases-and-users-from-the-command-line
you may be login as root but the root#localhost is not allowed for the actions you are executing.
mysql>CREATE USER 'root'#'localhost' IDENTIFIED BY 'enter_your_password_here';
mysql>exit
then try logging-in again
I think it's rights issue & It can be resolved by re configuring again. Here's a steps to reconfigure it.
Stop the current MySQL server instance:
sudo service mysql stop
Use dpkg to re-run the configuration process that MySQL goes through on first installation. You will again be asked to set a root password.
sudo dpkg-reconfigure mysql-server-5.5
Thanks for reply to all
i had solve i
1. first login to new user.
2. give access all to that users by update command .
3. drop root user and rename second user to root.
main problem was : when we create root it didn't give grant_priv field access users .

ERROR 1044 (42000) : Access denied for user ' '#localhost to database

Having trouble logging in and accessing my database. Currently using Windows 10 EasyPHP 13.1
I tried logging into my database. Using
"C:\Program Files (x86)\EasyPHP 13.1\binaries\mysql\bin\mysql.exe" -u jim -p;
An error message appeared saying
WARNING: Using a password on the command line interface can be insecure
ERROR 1045 (28000): Access Denied for user 'jim'#'localhost' (using password: YES).
Then I tried
"C:\Program Files (x86)\EasyPHP 13.1\binaries\mysql\bin\mysql.exe" -u jim;
This logged me in. However, I still cannot access the database.
Whenever I type the following command.
USE publications;
I get the error
ERROR 1044 (42000) : Access denied for user ' '#localhost to database 'publications'
I have even tried the following
GRANT ALL ON publications.* TO 'jim' IDENTIFIED BY 'mypasswd';
and
GRANT ALL ON publications.* TO 'jim'#'localhost' IDENTIFIED BY 'mypasswd';
and
GRANT ALL PRIVILEGES ON *.* TO 'jim'#'localhost' WITH GRANT OPTION;
as recommended at mysql> use mysql; but ... ERROR 1044 (42000): Access denied for user '' # 'localhost' to database 'mysql'
Even Logging in as a -u root won't let me access the database. I'm at a loss as to what the problem might be. Any ideas?
Try this:
"C:\Program Files (x86)\EasyPHP 13.1\binaries\mysql\bin\mysql.exe" -ujim
Notice i remove spaces between -u and jim
Try this:
GRANT ALL ON *.* TO 'jim'#'%' IDENTIFIED BY 'mypasswd';
FLUSH PRIVILEGES;

1044 - Access denied for user 'root'#'%' to database 'test' cleardb

I have an issue that when i try to connect to a database in cleardb it gives me this error:
1044 - Access denied for user 'root'#'%' to database 'test'
when it connect via navicat and try to upload new test.sql file to update my database i get the same error.
is there a way to do it?
Default root user in MySQL does not have permissions to access outside local host, so you should create a user to be able to do this like:
CREATE USER 'someuser'#'%' IDENTIFIED BY "your_password";
GRANT ALL PRIVILEDGES ON test.* TO 'someuser'#'%';
Then try connecting with this user

Unable to create the MySQL database on linux server

I have only one user. I am logged with the same user and tried to create the database and getting the following error.
ERROR 1044 (42000): Access denied for user 'csatsurvey'#'localhost' to database 'demo'
By the above error I understood that I am have some access issues. How can I grant the permissions and crate the database with the same user.
step 1: login to your mysql -u root -p
step 2: basic syntax to permission
"GRANT permission ON database.table TO 'user'#'localhost';"
step 3: To grant any specific permission
GRANT CREATE ON . TO 'testuser'#'localhost';
CREATE is a permission
to more details visit to
http://www.liquidweb.com/kb/grant-permissions-to-a-mysql-user-on-linux-via-command-line/

Error 1045 MySQL

I have a remote database which I connect through a sql management with a user and its password. The database has four tables and a view. To put the permissions I have executed the following command:
mysql> grant all privileges on databasename.* to 'username'#'%' identified by 'password' with grant option;
Then, all it's ok. When I connect to the database, I can see the data from the tables but if I explore the view, for example:
select * from viewname;
I get this error:
Error SQL (1045): Access denied for user 'username'#'%' (using password: YES)
I don't know what is the problem, because the rest of the database is OK.
Once you have given the desired privileges for your user, you will need to run this command within the MySQL command prompt:
Flush the privileges with this MySQL command: FLUSH PRIVILEGES;