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

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.

Related

"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.

The user specified as a definer does not exist - GRANT doesn't fix

After years of no problems with my PHP webapp running MySQL 5.5 on the backend, suddenly today I'm having permissions problems.
Whenever I try to run an INSERT statement (either from PHP or from Workbench or Heidi), I get this error message: The user specified as a definer ('my_user'#'1.2.3.%') does not exist
One symptom is that INSERT statements cannot be executed by my PHP nor by remote clients such as Workbench or Heidi. I have tried various solutions suggested by:
MySQL error 1449: The user specified as a definer does not exist
Error: 1449, "The user specified as a definer ('root'#'localhost') does not exist"
Everything points to running a GRANT statement. I have tried various GRANTs as suggested, but I always get this error:
Access denied for user
It seems like my permissions got corrupted or something. So I created a brand new DB user inside BlueHost control panel on my VPS and gave full privileges. I get the same exact errors on this brand new user.
BlueHost support has no idea what to do.
Some Stack articles say to go mess around with TRIGGERS or STORED PROCS permissions - but I don't have any of these types of objects. Simple INSERT statements cause this error, and perhaps UPDATEs as well, but I'm not sure of that at this moment.
The user has FULL PRIVILEGES, as always.
What else can I try? Is there some way to fix corrupted permissions? I can run SELECT statements with no problems.
I tried connecting to the DB with root (using the same pwd as I use when connecting to WHM), but it didn't like my password or maybe the user in general. I never set up root as a specific user against this DB and I'm not sure that's a good idea. I have always used a specific user created just for this DB. Again, past 5 years no problems at all. The DB has not been upgraded, no DB changes, no user changes, nothing.
I sort of solved it. I ended up creating a new database with a different name, and created a new admin user to go with it. Then I ran my db backup/dump script against it. Everything works perfectly again, with this new DB. The old DB is still jacked.
I'm thinking that permissions got corrupted in the old database.

Why does MySQL Select into outfile generate access error?

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.

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

Unable to create trigger on mysql system table [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
mysql: Cant we create triggers on system tables?
We are using MySQL ver 5.1.59 on rhel 6.1 (64 bit). We want to monitor the deletion of databases and for that trying to create a trigger on the db table of mysql database. We are creating the trigger by logging in as root user. the trigger written is as follows:
DELIMITER |
CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
TRIGGER `mysql`.`test` BEFORE DELETE
ON `mysql`.`db`
FOR EACH ROW BEGIN
INSERT INTO cescnet.db_monitor (DB_name,user_name,dateandtime,operation_type) VALUES (mysql.db.Db,CURRENT_USER(),NOW(),'Delete');
END;|
But we are getting the error:
Error Code : 1465
Triggers can not be created on system tables
As we are working as root user, we think we have all the permissions on the system. The global privilege for root user from any host including local host includes the SUPER permission. Can anyone help us please?
I'm going to take a wild guess and say the reason you're getting that error message is that triggers can not be created on system tables.
Oh, perhaps I can add "regardless of privileges"
In short : You can not do.
I have also tried things like
See (All) and (Super) Privileges Provided by mySql
After trying all type of privileges like
grant super on *.* to root#localhost
grant all on *.* to root#localhost
I have tried simplest trigger and get same error
Triggers can not be created on system tables
If you found anywhere that triggers can be created on system tables, simply that is wrong