I am unable to login to mysql unless I provide exact case match for a user I have in my database.
After looking into the issue I believe my problem is with the collation but I am not sure. I tried to alter collation for the mysql.user table, User column to be latin1_swedish_ci but still could not get it to recognize alternate cases for usernames when I try to login.
My new username is admin ( all lowercase)
The command I am running is
mysql -u admiN -p <------ with username ending in a capital letter
Prior to running the command I ran the SQL statement below.
Here is the command I ran with apparently no effect (Original Collation was utf8_bin)
ALTER TABLE `user` CHANGE `User` `User` CHAR(16) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '';
Each time I get the following response.
ERROR 1045 (28000): Access denied for user 'admiN'#'localhost' (using
password: YES)
Only when I login with all lowercase for the username do I succeed in entering into mysql.
Am I missing something else here to get it working? How do I change the mysql configuration to accept case insensitive usernames?
I am using mysqldump to save my database and now want to reconstruct it completely, including the database, the users, and the user permissions.
mysqldump --databases my_db mysql -u root -p > mysqldump.sql
This generates the sql to create the database and it creates the user in the following table:
INSERT INTO db VALUES ('localhost','my_db','my_user','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
However, the password for the user does not appear anywhere in the file and it's not clear to me how I can use the user to access the DB once I have recreated the DB.
I cannot use the --all-databases option because there is another DB with tons of data and I do not want that in the file.
You are looking at the incorrect table in your dump:
Look at the table:
CREATE TABLE `user` (
`Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
`User` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
`Password` char(41) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL Etc
The INSERT statement after that contains your passwords
The user name and password are not part of the database, but are part of the special mysql database. If you want to replicate the user accounts, take a dump of the mysql database and restore it on the other end and then use flush privileges command to refresh the user table in the DB.
Whenever you assign privilege to any user then entry goes as per below-
If you are assigning privileges on all dbs like . then entry will go only in user table.
If you are assigning privileges db wise like mydb.* then one entry will go in user table which contains all privilegs with 'N' permission & keep user password there and 2nd entry in db table which contains appropriate rights.
mysql db contains user privileges as per below-
global rights (all db) with user anme and password : user table
db wise rights in : db table
table wise rights in : tables_priv table
column wise rights in : columns_priv table.
So you are checking db table, which contains db wise rights but not password as password is stored only in user table.
Error
SQL query:
--
-- БД: `mlrp`
--
CREATE DATABASE IF NOT EXISTS `mlrp` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
MySQL said: Documentation
#1044 - Access denied for user 'vfwx10mx'#'localhost' to database 'mlrp'
you need that root user will grant privileges to this user.
look for what you need in here:
http://dev.mysql.com/doc/refman/5.1/en/grant.html
So use this:
GRANT ALL ON mlrp.* TO 'vfwx10mx'#'localhost';
I have installed mySQL Server and created a user called ej_instance and has set password "password". Logged into server using below command
mysql -u ej_instance -p;
-- entered password
ej_instance has access to only ejabberd database. So I executed command like below
use ejabberd;
Then tried to execute commands like below
SET table_type=InnoDB;
CREATE TABLE users (
username varchar(250) PRIMARY KEY,
password text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) CHARACTER SET utf8;
But it is throwing errors at me. Below are errors
ERROR 1193 (HY000): Unknown system variable 'table_type'
ERROR 1046 (3D000): No database selected
How can get this done? anything else to be changed?
Specify the engine type when creating the table, like this:
USE ejabberd;
CREATE TABLE users (
username varchar(250) PRIMARY KEY,
password text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) CHARACTER SET utf8 ENGINE = INNODB;
If the use error still showing, check:
the database exists
the user ej_instance has privileges to access and create tables on the database
Loggin as root:
#check the database exists
SHOW DATABASES LIKE 'ejabberd';
#check user permissions
SHOW GRANTS FOR 'ej_instance'#'localhost';
SHOW GRANTS FOR 'ej_instance'#'%';
If don't have enough permissions:
#grant all permission on the user for the specified database
GRANT ALL ON ejabberd.* TO 'ej_instance'#'localhost';
GRANT ALL ON ejabberd.* TO 'ej_instance'#'%';
FLUSH PRIVILEGES;
I am trying to import my old database back into phpmyadmin after deleting it and creating a new one...steps taken....deleted database after back up....created new database with different name and received this error when trying to import
1044 - Access denied for user 'augr_2'#'%' to database 'augr_2'
After some research i found that i must change my CREATE DATABASE line in my database .sql file after amendment it looked like this
CREATE DATABASE `augr_2` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `augr_2`;
But i still keep getting this error?
this is the full error i receive
SQL query:
--
-- Database: `augr_2`
--
CREATE DATABASE `augr_2` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
MySQL said:
1044 - Access denied for user 'augr_2'#'%' to database 'augr_2'
It looks like the mysql used by the PMA doesn't have rights on the newly created db , which is normal.
Try this logged it as root
GRANT ALL ON *.* TO 'augr_2'#'%';
FLUSH PRIVILEGES;