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';
Related
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';
Could not able to connect to the remote mysql server using mysql workbench or direct command line.
When trying it resolves different hostname
When trying directly through command line
mysql --host=10.37.1.92 --port=3306 --user=root --password=password
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'#'myaapvm.local' (using password: YES)
Tried, with password and without password, no luck.
I tried to connect to 10.37.1.92 server but my mysql client try to connect to different server. The only way I can try now is directly login to the machine and do the change in my DB. I have disabled firewall in my mysql DB. Does anyone faced this issue please help.
This server running with maria DB installation.
By default root is not allowed to access the database by using a remote connection. I recommend that you create a new user that will be used for remote connections. You can do that by using the following SQL commands:
CREATE USER 'myuser'#'localhost' IDENTIFIED BY 'mypass';
CREATE USER 'myuser'#'%' IDENTIFIED BY 'mypass';
GRANT ALL ON *.* TO 'myuser'#'localhost';
GRANT ALL ON *.* TO 'myuser'#'%';
FLUSH PRIVILEGES;
You also need to modify your my.cnf if you didn't do that already.
#Replace xxx with your IP Address
bind-address = xxx.xxx.xxx.xxx
I created a new user in Mysql, with restricted privileges to do anything with only one VIEW ( GRANT ALL ON mydatabase.myview TO 'myuser'#'localhost'
When I try to connect with this user on DataStudio I got the message 'User denied" but when I try to connect using any other tool like sequel pro .. the connection is successful.
My question is: What Privileges are needed to connect with restricted users in DataStudio? They need to show all databases? show all tables? or any other grant ???
By setting 'myuser'#'localhost' you explicitly allow myuser to connect only from localhost aka your computer.
Google Data Studio operates on the Web, thus does not have access to your local network (see
https://support.google.com/datastudio/answer/7088031?hl=en#notes), unlike Sequel Pro which is running locally on your personal computer.
To start with, the correct user to create would be 'myuser'#'%'
I am trying to connect to my database through an ash tunnel using sequel pro but it is not working and forces me to use 127.0.0.1 when entering "localhost" which leads to the problem where if I run on the command line:
mysql --host "localhost"
It works
If I run:
mysql --host "127.0.0.1"
I get the access denied error:
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
What is going on?
I have tried:
update user set host='%' where host='localhost'
but this does not work.
Many SQL servers have two or more different user entries for every user that might come in via either localhost or remote. (127.0.0.1 counts as remote).
For example, for the root user, you might have these three user entries.
CREATE USER 'root'#'localhost' IDENTIFIED BY REDACTED;
CREATE USER 'root'#'127.0.0.1' IDENTIFIED BY REDACTED;
CREATE USER 'root'#'%.example.com' IDENTIFIED BY REDACTED;
There's nothing much special about the name root except that it has been granted a lot of privileges when your MySQL was installed. You need to grant the same privileges to the other versions of root#whatever you create.
I created a new user:
CREATE USER 'non-root'#'localhost' IDENTIFIED BY '123';
and then granted them all the same privileges:
GRANT ALL PRIVILEGES ON * . * TO 'non-root'#'localhost';
and then deleted root and renamed non-root to root
and now it finally works.
I am working on a project for a client, and instead of using my usual 'root' SQL password, I needed to create a new User/Password with specific access rights. I looke up how to do this and found that I should use the following:
CREATE USER 'AppSrv'#'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON some_db.* TO 'AppSrv'#'%' WITH GRANT OPTION;
When I run select * from mysql.user; I can see that the user has been added to the table, however when using PDO or PHPMyAdmin I get an error stating: Access denied for user 'AppSrv'#'localhost'
I have created users in the past without a problem, and am not sure why it is now not working. I have attempted rebooting the SQL server as well with no avail.
Running:
Linux version 3.2.0-24-virtual (buildd#crested) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) )
MySQL v5.5.28-0ubuntu0.12.04.3 - (Ubuntu)
What could be a possible fix to create new users for my SQL Server?
EDIT
I have also tried using PHPMyAdmin to create the user, and even that fails when trying to login.
Create the account with #'localhost':
CREATE USER 'AppSrv'#'localhost' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON some_db.* TO 'AppSrv'#'localhost' WITH GRANT OPTION;
Otherwise the anonymous-user account for localhost that is created by mysql_install_db would take precedence - see mysql doc adding users or access denied