I have installed Mysql on Mac os 10.7 using dmg installer, it got installed at location /usr/local/mysql I also installed MySQL.prefpane, where I can start and stop the server using services.
i am facing below problems.
mysql> create database test ;
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'ets'
same happens when I am trying to invoke mysql by using below command
./mysql -u root root
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Even when I created a connection using Eclipse to mysql db then also I got similar kind of exception.
Just want to know after installation do I need to make any further configuration related to user management and access privileges?
Try this,
./mysql -uroot -pPassword
To give the user all priviliges, execute this command:
GRANT ALL PRIVILEGES ON *.* TO root#'%' IDENTIFIED BY PASSWORD 'yourpassword' WITH GRANT OPTION
Also try
CREATE SCHEMA test;
Related
How do I grant permissions to users in MySQL?
This is the order in which I tried:
First, connect from EC2 SERVER to MYSQL CLIENT RDS.
After connecting, MYSQL created a user to give you permission.
An error occurs when giving the user permission.
My attempt:
mysql> CREATE USER 'injekim'#'125.128.63.112' IDENTIFIED BY 'k12345678!!';
Query OK, 0 rows affected (0.02 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'injekim'#'125.128.63.112' WITH GRANT OPTION;
ERROR 1045 (28000): Access denied for user 'root'#'%' (using password: YES)
ERROR 1045 (28000): Access denied for user 'root'#'%' (using password: YES)
Also, I found similar error information in stackoverflow, but I couldn't solve it.
MySQL ERROR 1045 (28000): Access denied for user 'bill'#'localhost' (using password: YES)
How can I authorize the user who created it?
It looks like you are not logged into the host machine. To use the root user, you should actually be logged into the machine (ssh or rdp) that is hosting the MySQL server.
Example, let's say I am setting at my Mac but need to give a new user access to a MySQL database that is running on a server with an IP address of 192.168.1.10. Assuming it's a Linux server I would ssh to the server from my Mac's terminal by running:
ssh myuser#192.168.1.10
You can now either:
Log into MySQL as root by running: mysql -u root -p (you will be prompted for the password)
Or,
You could become the root user. In my case, I would run the following:
sudo su. Now that you are the root user, you can log into MySQL by running:
mysql -p
If you need an example in a Windows environment, let me know. It will be the same basic idea, but using RDP instead of ssh. From your local machine, get a session on the actual server running MySQL and then log into MySQL as root from the server.
Relatively new to SQL, I am reaching out for any advice on how to access MySQL via the Terminal shell on a MAC OSX 10.7.5 system. I have gotten this far detailed in the script below, and followed all installation guides on the web, as well as doing a fair amount of troubleshooting to try and move past the "ACCESS DENIED to "KV88#localhost, PASWORD: NO".
Can anyone provide insight on to why I can't input regular MySQL syntax and access the server, I believe I am still stuck in the BASH script environment.
SCRIPT:
ClickAways-MacBook:~ KV88$ sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
Starting MySQL database server
ClickAways-MacBook:~ KV88$ /usr/local/mysql/bin/mysql
ERROR 1045 (28000): Access denied for user 'KV88'#'localhost' (using password: NO)
ClickAways-MacBook:~ KV88$
Thanks in advance
During the installation you had to be asked about root password. So, you can access the server like this:
mysql -u root -p
and input your password. Then give access to your user:
GRANT ALL PRIVLIEGES ON *.* TO 'KV88'#'%' IDENTIFIED BY "<password>";
if you want for a user to be able to do (almost) everything, or create a database under root and give access to this database:
CREATE DATABASE mydb;
GRANT ALL PRIVLIEGES ON mydb.* TO 'KV88'#'%' IDENTIFIED BY '<password>';
Then exit mysql and enter as a user:
mysql -u KV88 -p
or
mysql -u KV88 -p mydb
I'm running Homestead via Vagrant for a local Laravel install. I logged into Homestead via ssh (vagrant ssh), and connected to MySQL using the host localhost, user homestead, password secret. I was able to connect successfully, and running show databases; tells me there's an information_schema database in there. I thought all was well and I could create a new database for my Laravel project and get going.
Unfortunately, running CREATE DATABASE mynewdb; returned:
ERROR 1044 (42000): Access denied for user 'homestead'#'localhost' to database 'mynewdb'
I tried giving the homestead user some more privileges via:
GRANT ALL PRIVILEGES ON mynewdb.* TO 'homestead'#'localhost' WITH GRANT OPTION;
But get back a similar access denied message:
Access denied for user 'homestead'#'localhost' (using password: YES)
I tried a few other variations of that command, using '%' instead of 'localhost', for instance, but it seems like my homestead user just doesn't have the priviliges needed to administrate this db fully.
I thought I should be able to simple restart the mysql service with the --skip-grant-tables flag, and then login as homestead or root and have full privileges. This also failed to work:
vagrant#homestead:~$ sudo /etc/init.d/mysql stop
[....] Stopping mysql (via systemctl): mysql.servic[.ok
vagrant#homestead:~$ sudo /etc/init.d/mysql start --skip-grant-tables
[....] Starting mysql (via systemctl): mysql.servic[.ok
vagrant#homestead:~$ mysql -h localhost
ERROR 1045 (28000): Access denied for user 'vagrant'#'localhost' (using password: NO)
vagrant#homestead:~$ mysql -h localhost -u homestead
ERROR 1045 (28000): Access denied for user 'homestead'#'localhost' (using password: NO)
vagrant#homestead:~$ mysql -h localhost -u root
ERROR 1698 (28000): Access denied for user 'root'#'localhost'
vagrant#homestead:~$ mysql
ERROR 1045 (28000): Access denied for user 'vagrant'#'localhost' (using password: NO)
After those attempts, I logged in with homestead and secret, just to check and see if anything had changed:
vagrant#homestead:~$ mysql -h localhost -u homestead -p
mysql> create database mynewdb;
ERROR 1044 (42000): Access denied for user 'homestead'#'localhost' to database 'mynewdb'
Finally, I noticed in my homestead.yml file that there was an entry that looked like this:
databases:
- homestead
I modified this entry to:
databases:
- homestead
- mynewdb
And then rebooted the homestead VM:
vagrant halt
vagrant up
And then tried again to create the new datbase with the homestead MySQL user. None of this did anything, access is still completely denied for the homestead user trying to do just about anything.
Suggestions to gain access?
I didn't have the patience to try and solve this, as it clearly was not acting right at all. I finally just destroyed the Homestead VM and all its files after backing up my configuration, and reinstalled the machine. Booted it up, and how the homestead user has full access as it should. Not sure what the heck could have happened to it last time, but the lesson here is: Initializing new VM's is cheap, fighting with the wrong permissions is expensive.
If anyone has an explanation as to how I could have fixed this, I'll accept their answer. Otherwise, reinstalling Homestead seems to be the fastest solution.
To login into MySQL as root user, you can use:
mysql -u root -p
and then enter your MySQL password.
To login as another user, you will have to create that user first and grant him privileges.
Create the user using - change newuser to the username you want and password to your password of choice.
CREATE USER 'newuser'#'localhost' IDENTIFIED BY 'password';
Sadly, at this point newuser has no permissions to do anything with the databases.
Therefore the first stage is to grant the user the privileges to do 'things'.
To grant all privileges (select, create, delete, update, drop, etc) on all databases and tables, run:
GRANT ALL PRIVILEGES ON * . * TO 'newuser'#'localhost';
To grant a specific privilege on a particular database and table, just run:
GRANT [type of privilege] ON [database name].[table name] TO '[username]'#'localhost';
If you ever need to deny or revoke a certain privilege, just run:
REVOKE [type of permission] ON [database name].[table name] FROM '[username]'#'localhost';
EDIT- Turns out to be a silly question. The solution:
mysql -u root Don't put a -p as there is no password for fresh installs of MySQL root.
Original Question:
Autoparts just came out recently on nitrous: http://blog.nitrous.io/2013/09/18/introducing-autoparts-for-nitrous-io.html
and I ran the command $ parts install mysql to install mySQL...works great!
Now, how do I access mysql to setup a root user or other users?
mysql> CREATE DATABASE django_db;
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'django_db'
mysql> GRANT ALL ON django_db.* TO 'djangouser'#'localhost' IDENTIFIED BY 'mypassword';
ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'django_db'
I don't know how to access mysql -u root -p because I don't know the root password, so I just used mysql to access the mysql from the terminal.
My end goal is to have the mysql setup on my box for a development and testing for my django web application.
I installed MySQL to my Mac (with MAMP installer) and have a problem. When I create a user with "#%" hostname this way:
CREATE USER 'test'#'%' IDENTIFIED BY 'test';
and I try to connect via CLI: mysql -u test -ptest, I get this error:
ERROR 1045 (28000): Access denied for user 'test'#'localhost' (using
password: YES)
But when I change hostname to localhost:
RENAME USER 'test'#'%' TO 'test'#'localhost';
it works.
Any idea how to make MySQL use the wildcard?
Thanks.
As YaK suggests, it is because of anonymous user ''#'localhost' created by MySQL installation. Problem was solved after removal of this user. Thanks a lot YaK!