Why does MySQL Select into outfile generate access error? - mysql

My question may really be, why can't MySQL write to /tmp. The server version is : Server version: 5.1.73 Source distribution
Here are the details: I have looked through some of the suggested posts that popped up when I wrote the title to this post. I have also looked at this post and Snow Crashe's answer. I've looked again at one of my own posts and then searched the MySQL documentation hoping to find an option like INTO LOCAL OUTFILE, but such an option appears not to exist.
When I issue the following sql query, I get an access denied error.
SELECT *
INTO OUTFILE '/tmp/feb_gic.txt'
FROM gic_employees
WHERE bill_month='201502';
My user has all privileges to a MySQL database given through grant.
So, after reading all this, why can't MySQL write to /tmp? MySQL cannot write to /tmp even if my user is logged into mysql, let alone if mysql -e is used.

Related

MySQL SQL> ERROR: Not connected. Problem with creating a MySQL user

I asked this question here an hour ago. I got a message that my question is closed, because it already has an answer here: Create new user in MySQL and give it full access to one database. However, I think this is a mistake because I didn't find anything relevant there! So I'm trying to ask again (hopefully that's okay):
I'm trying to create a database using MySQL.
I understand that I need to create a user to do so, and then I can create a database and use it in my python project. is that correct?
this is what I tried to run in the MySQL Shell:
MySQL JS > \sql
MySQL SQL > CREATE USER 'myname'#'localhost' IDENTIFIED BY 'mypassword';
I wanted to continue with:
MySQL SQL > GRANT ALL PRIVILEGES ON * . * TO 'myname'#'localhost';
but I got this error- ERROR: Not connected
I looked up ways to fix it, but the only way I found was for people who already have a user.
Does anyone know how to fix this? Thank you.

"use db_name" fails with error #1046 on MySQL, message = "no database selected"

I haven't used MySQL for a while, so forgive me if this is a silly issue with a simple solution. I have checked similar questions on the site, and in the majority of cases, the asker simply forgot to create or specify the database. This is not the case here.
I get the message
Error: #1046 No database selected
After running the following instruction
USE db_name;
For example:
USE test;
I've tried several databases, but I get the same error with all of them. Creating databases works, that is, the database is created, but the same error message is still shown. If I try to SELECT * on a table from an existing database after specifying it:
USE db_name;
SELECT * FROM table_name;
I get the error:
#1146 - Table 'db_name.table_name' doesn't exist
I'm using MariaDB, version 10.4.14 with root user.

Jawsdb on heroku, new database post migration, (Mysql2::Error: INSERT command denied to user..?)

Deployed a new version of our app on heroku and migrated over database from previous free jawsdb instance. However now every time user signs up gives
(Mysql2::Error: INSERT command denied to user <username for instance
what have i missed
migrated using a dump and re-import using mysql command line. eye balled exported data and it seems to be there (user emails etc)
all config vars look ok (DATABASE_URL is mysql2...)
i can login to the database via the url
I have not had to grant access or anything like that before, anyone come across this?
thanks
Ben
My guess is they disabled your INSERT grant because you have reached your max Storage Capacity for your plan.
To validate this is a permissions problem, log into a MySQL prompt with the user the app is running as, and enter this query:
SHOW GRANTS;
It probably list many, but no INSERT.
See this link. As explained in given link, jawsdb preliminary plan does not give you permission to add a new database. You are provided with one schema with some random name and you have to work with that only.
Check your migration
e.g. Make sure the database name matches.
For me, I got the same error as OP when trying to migrate my data. This was a fresh account with only a 50kb'ish database; nowhere close to the free-plan 5mb limit.
In my SQL export statement, my local database name is being used, however the remote MySQL (ie JawsDB) service auto-generates a db name, which will obviously not be the same. Simply used find-replace to change the database name to match remote; everything works.

Same query times out - Lost connection to MySQL server during query

I know this question has been asked on here before, but it seems like I've tried everything suggested in this answer and this answer, and still no luck. I'm trying to use MySQL Workbench 6.3 on a Windows 10 client, connecting to a Linux MySQL server hosted by GoDaddy/cPanel.
I can connect to the MySQL server with no problems, and usually I have time to run a query or two. Then, within a minute of inactivity between Workbench and the server, I'll run into Error 2013: Lost connection to MySQL server during query. This even happens when running the exact same query, back to back about a minute apart, as shown here (even when the original query is quick; only 0.03 seconds to run):
The same problem persists when I run select sleep(60) immediately upon connecting to the MySQL Server; the connection is usually lost between 30-40 seconds into the execution of the query:
I've checked the MySQL docs, but with no luck. I don't think the problem can be related to packet size, as others have suggested (since the same query will work and then fail later), and my Workbench timeout settings look okay:
Anyone have any idea? The only other thing I can think of is maybe the wait_timeout variable listed in the MySQL docs needs to be increased too, but I guess that would be somewhere on the server side (some have mention my.ini) and I can't find where any MySQL Server files live in the cPanel hosting admin interface. There's a MySQL online client provided through cPanel (phpMyAdmin I think), but it's not nearly as robust and is becoming cumbersome to use. Any help would be appreciated!
I was having the same problem, using MySQL Workbench 6.3.6 on Win10 to connect to a MySQL server on a shared hosting system (Arvixe).
In addition to to the problem described by the OP (lost connection to server), I was also getting an error when attempting to import data from a prior export (similar to what is described here):
Unhandled exception: Error querying security information: Error executing 'SELECT * FROM mysql.user WHERE user = '[username]' and Host = '[host]' ORDER BY User, Host' SELECT command denied to user '[username]'#'[host]' for table 'user' SQL Error: 1142
Apparently, a bug was introduced in MySQL Workbench 6.3.5 (bug report). From the bug report:
It appears the problem arise if connecting with an user with no privileges on the mysql schema.
In other words: users connecting to a shared hosting system.
The proposed solution is to uninstall MySQL Workbench 6.3.6, and install 6.3.4 instead. (6.3.4 can be found in the archives). This solution worked for me.

Easy PHP and mysql ..php cannot see database on local pc (all works on server)

I have a website written in php and mysql (written by someone else) and I need to alter it- just for your interest it is bridgetjonesart.co.uk. So I thought I would download it to my desktop pc and use easy php and mysql locally to make changes then upload it again.
I seem to have downloaded everything okay. I first just tried to run existing php using Easy Php and got
Warning: mysql_connect(): Access denied for user 'runningc'#'localhost' (using password: YES) in C:\Program Files (x86)\EasyPHP-12.1\www\backup from runningc\public_html\bridgetjonesart.co.uk\mysqlLogin\mysql_connect.php on line 6
Could not connect to database. Error
I have the sql database as a file 'runningc_bjart.sql' in the root directory but I think the php cant see it so I tried to use easy php administration, phpmyadmin and thought perhaps I should import the 'runningc_bjart.sql' file. So I tried and got an error message ...
Error
SQL query:
--
-- Table structure for table `Blog`
--
DROP TABLE IF EXISTS `Blog` ;
MySQL said: Documentation
#1046 - No database selected
I am not sure what to try next, any help would be really appreciated.
Thank you. Bridget
The error messages are VERY clear.
Error #1: You're using the incorrect credentials, or have forgotten to grant rights on your database to the credentials you're using.
Error #2: You've forgotten to set a default database, so MySQL has no idea which database it should be looking in for the table you're trying to drop.
e.g. you need
mysql_select_db('mydatabase');
or change your DROP query to be
DROP TABLE mydatabase.Blog;
With phpmyadmin, create a new database named runningc_bjart and import the file there. Then search in your project for a config file where the db password is set and change it with your local mysql password