MYSQL error: Can't create database 'publications'; database exists - mysql

I run this command in mysql:
mysql > show databases;
My database called publications is there so I want to use it:
mysql > USE publications
But I get an error:
ERROR 1049 (42000): Unknown database 'publications'
mysql > CREATE DATABASE publications;
ERROR 1007 (HY000): Can't create database 'publications'; database exists
Have I corrupted something? It is on XAMPP on thumb drive. What does this error mean?

you may not have permissions. open up the mysql database, and double check that mysql.db table has the user you are logged in as set up to read, write, etc.. as appropriate. after changing permissions, don't forget to FLUSH PRIVILEGES

Related

unable to truncate a table using remote login

I use remote login to connect to the database (residing on AWS). I'd like to truncate one of my tables. But this command does not seem to work on bash:
mysql --login-path=remote --database=marketing 'truncate table my_test_table'
I get the message
ERROR 1044 (42000): Access denied for user 'mdb_updater'#'%' to
database 'truncate table pedram_test_table'
mdb_updater is my username on the database.
This is when I can successfully run mysqlimport and mysqldump using the same credentials.
MySQL cli treats positional argument as database name, pass statement you want to run with --execute option:
mysql --login-path=remote --database=marketing --execute 'truncate table my_test_table'

CREATE USER MySQL

Error with dropping tables:
SQL query:
DROP user IF EXISTS 's01'#'%';
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to
use near 'if exists 's01'#'%'' at line 1
Error without dropping tables:
SQL query:
/*Students*/ CREATE User 's01'#'%' IDENTIFIED BY 'pw1';
MySQL said: Documentation
#1396 - Operation CREATE USER failed for 's01'#'%'
Example of some of my code:
Drop user if exists 's01'#'%';
flush privileges;
/*Students*/
Create User 's01'#'%' Identified by 'pw1';
I don't exactly know what is wrong. I looked it up and it said add flush privileges, but I still get the same two errors.
Check your version of mysql with select version();. The IF EXISTS option for DROP USER was added in 5.7. If you're not using 5.7, then that likely explains your first error.
Check if the user exists by querying mysql.user table.
select user, host from mysql.user where user = 's01';
Also since you are not specifying a hostname, just execute
DROP user IF EXISTS 's01';
Create User 's01' Identified by 'pw1';
The wildcard host (#'%') is implied.
Also execute SHOW GRANTS to verify that your user has the correct privileges to create and drop users.

why the table of information_schema is damaged?

I want to get information from COLUMNS of information_schema. I execute the following command:
root:information_schema> select * from COLUMNS;
but it occur the error:
ERROR 126 (HY000): Incorrect key file for table '/tmp/#sql_11b6_0.MYI'; try to repair it
So I want to repair the table. I execute the following command:
root:information_schema> repair table COLUMNS;
but it occur error again,the wrong content follow:
ERROR 1044 (42000): Access denied for user 'root'#'localhost' to database 'information_schema'
I don't why the root user have no privileges to repair the table
When you see something like '/tmp/#sql_XXXXX_X.MYI', the problem is your file system is full and the temporary file needing to be created can't be written to. Remove any unnecessary files and try again.

Mysql Workbench priveleges, data import

When I try to change the priveleges on a mysql db I get the following error:
Please make sure the used account has rights to the MySQL grant tables. Error executing 'DESCRIBE mysql.db'
Is this also why it will not let me import tables in from another DB? When i try I get the error:
Operation failed with exitcode 1
09:20:16 Restoring D:\design and photos\boo.com\db dump\070113.sql
Running: mysql.exe --defaults-extra-file="c:\users\darren\appdata\local\temp\tmpslubjs.cnf" --host=87.117.239.19 --user=boo8_yu52 --port=3306 --default-character-set=utf8 --comments < "D:\design and photos\boo.com\db dump\070113.sql"
ERROR 1044 (42000) at line 1: Access denied for user 'boo8_yu52'#'%' to database ' boo8_6652'
It does however let me create tables manually. Can't work it out at all.
make sure that the account you are using is granted with grant option
and the account should have permissions on mysql database in which the db grant table exits
or the best way is to assign the permission with the root account
see the link below may be useful for you
http://blog.loftninjas.org/2008/04/22/error-1044-42000-at-line-2-access-denied-for-user-root-to-database-db/

How can I create a MySQL-database

I tried to create a database by the following command:
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,ALTER,INDEX,DROP,
-> CREATE TEMPORARY TABLES,SHOW VIEW,CREATE ROUTINE,ALTER ROUTINE,
-> EXECUTE,CREATE VIEW,EVENT,TRIGGER
-> ON {projekti_db}.*
-> TO '{asiakas}'#'localhost';
and got the following error message
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near '{projekti_db}.*
TO '{asiakas}'#'localhost'' at line 4
I have MySQL 5.1.37. What am I doing wrong?
You are trying to assign roles to a user on a certain database. To create a database, use
CREATE DATABASE NAME;
That syntax doesn't create a database, it grants db privileges to a user.
To create a database, you'd use:
CREATE DATABASE projekti_db;
See here for a quick cheat sheet for MySQL.
#
# First create the Database
#
CREATE DATABASE projekti_db;
#
# Then Create the User that will access that database
#
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,ALTER,INDEX,DROP,
CREATE TEMPORARY TABLES,SHOW VIEW,CREATE ROUTINE,ALTER ROUTINE,
EXECUTE,CREATE VIEW,EVENT,TRIGGER
ON projekti_db.*
TO 'asiakas'#'localhost';
#
# Now verify that the user asiaskas can access the projekti_db only from localhost
#
SHOW GRANTS FOR 'asiakas'#'localhost';
Give it a Try !!!