Fail to run mysql script for other user than root - mysql

I have mysql installed on ubuntu server. There is a mysql script that has a select statement in it. I want to output the result of this select into .csv file.
If I run the following command
mysql -u root -pTHIS_IS_PASS MY-SCHEMA < /home/me/script.sql
things work out beautifully. I, however, I run
mysql -u OTHER-USER -pTHIS_IS_PASS MY-SCHEMA < /home/me/script.sql
I get this error:
ERROR 1045 (28000) at line 7: Access denied for user 'OTHER-USER'#'localhost' (using password YES)
I have no escaping characters in the password of OTHER-USER.
How can I fix this?

Found out the solution myself: I needed to grant FILE permission to the OTHER-USER.
GRANT FILE ON *.* TO 'OTHER-USER'#'localhost';
Don't forget that file permission is granted not to just one schema, but to the whole mysql.

Related

Problems with mysql on linux and also importing a dump from windows

I'm a beginner with linux (linux mint distro) and I have been trying to install mysql server and workbench. I couldn't connect to mysql server without sudo command. I tried to connect to the server on workbench, and Access denied for user 'root'#'localhost'. So I try to run workbench with sudo from terminal. Nothing. So I followed what somebody posted here on stackoverflow about changing my password auth mode to mysql_native_password, and was able to access SQL Server from workbench (only using sudo command).
So I try to import a dump which I made on windows mysql-workbench, and it gives me two errors:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
and
ERROR 1115 (42000) at line 24: Unknown character set: 'utf8_general_ci'
Nevertheless, the database seems to have been correctly imported (I can see values and columns and tables and they look alright).
What's happening and how to stop getting these access denied errors? I tried to search the web and there are different answers, but none of them seem to address first install. I don't see why wouldn't it work if I have made a pretty default install :(
Thanks a lot!
ps: I don't know if more specific info is needed. anonymous user was dropped after installation
Try resetting root password.
Step 1. Access to mysql using mysql -uroot
Step 2. Check the root user
select Host, User, authentication_string from mysql.user;
Step 3. Change password for root user
use mysql;
update user set authentication_string=password('NEWPASSWORD') where user='root';
flush privileges;
​quit;
Now try accessing to mysql using mysql -uroot -p using new password. If it works, use the credentials in workbench.

Installed MySQL Server on Mac OSX 10.7.5, receiving a 1045 (28000) error when trying to access MySQL

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

Cannot log in to mysql using root

So I'm setting up mysql for the first time.
I read somewhere that I have to run this
mysql -u root -p
To log in as root, in order to be able to create tables/databases using the mysql command line.
When I run this, I get prompted for a password - I hit enter (I thought the default password was blank).
I get this error
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
What's going on?
If you have a fresh installation of MySql you should be able to issue the following command and it should allow your connection.
xyz#ubuntu$ mysql -u root mysql
You then should set the root password and then create a user with the correct level of access.
look HERE for help connecting.

How to grant privileges to root in mysql through SSH

I am trying to install the Clouse script on our server and I am connecting via SSH.
Everytime I get to the install part in SSH I am getting this error:
ERROR 1142 (42000) at line 1: INSERT command denied to user 'root'#'localhost' for table 'plugin'
I tried connecting to mySQL by typing my in the command line, once I am connected I try running this (for demo purposes this is false info - skittles would be my database, password1234 would be the password):
GRANT ALL ON skittles.* TO root#'localhost' IDENTIFIED BY 'password1234';
It tells me success that 0 rows were effected in 0 seconds and then I use FLUSH PRIVILEGES
then quit and try to install again and keep getting the same error. Is there something I am doing wrong in the command line with the GRANT ALL ? Not sure why it is not working, not familiar with SSH to much so I would appreciate any insight

I can't set the root password for MySQL

I've just set up a LAMP server using SuSE Server 10. I want to set the root password for MySQL, so I entered the following in the terminal:
mysqladmin -u root password MyPassword
and the output is:
mysqladmin: Can't turn off logging; error: 'Access denied; you need SUPER
privilege for this operation'
I'm not really certain what SUPER privilege is for mysqladmin, and all my Google searches have been fruitless. I am able to use mysql from the command line without entering a password like this:
mysql -u root
But I can't access the mysql database to update the root password that way. Here is the output:
mysql> USE mysql;
mysql> ERROR 1044 (42000): Access denied for user ''#'localhost' to database 'mysql'
Any help would be greatly appreciated. Thanks.
I am still unsure what the solution to this problem is, but the solution I came up with was to install SuSE 11. Everything is working now. I think there was just a problem with my initial install.