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;
Related
When i enter this SQL snippet into phpMyadmin nothing happens, and no error message is returned.
What can I do to fix it?
CREATE DATABASE `moodle`
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER ‘moodle-owner’#’localhost’;
CREATE USER ‘moodle-owner’#’127.0.0.1’;
CREATE USER ‘moodle-owner’#’::1′;
SET PASSWORD FOR ‘moodle-owner’#’localhost’ = PASSWORD(‘moodle123$%’);
SET PASSWORD FOR ‘moodle-owner’#’127.0.0.1’ = PASSWORD(‘moodle123$%’);
SET PASSWORD FOR ‘moodle-owner’#’::1′ = PASSWORD(‘moodle123$%’);
I'm not sure what version of MySQL you are running, but in 5.7, the SET PASSWORD is deprecated. Try setting the user passwords with IDENTIFIED BY in the same query as CREATE USER.
CREATE USER 'moodle-owner'#'localhost' IDENTIFIED BY 'moodle123%';
CREATE USER 'moodle-owner'#'127.0.0.1' IDENTIFIED BY 'moodle123%';
CREATE USER 'moodle-owner'#'::1' IDENTIFIED BY 'moodle123%';
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.
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;
This question is based on this thread.
I run unsuccessfully
sudo mysql
\. /users/cs/SO_db/posts.sql
I get the error
ERROR 1146 (42S02): Table 'personal.posts' doesn't exist
MySQL's manual says
A five-character SQLSTATE value
('42S02'). The values are specified by
ANSI SQL and ODBC and are more
standardized. Not all MySQL error
numbers are mapped to SQLSTATE error
codes. The value 'HY000' (general
error) is used for unmapped errors.
and
Error: 1146 SQLSTATE: 42S02
(ER_NO_SUCH_TABLE)
Message: Table '%s.%s' doesn't exist
How can you solve the error message?
The SQL script you have loaded makes reference to a database and/or table which does not exist in the database.
Typically one would not call the mysql tool with sudo, as the system user privileges are different from MySQL users.
To execute an SQL script through mysql I would try something like:
cat somefile.sql | mysql -u <mysqluser> -p <mysqldb>
This command would load 'somefile.sql' into mysql tool, connecting to a MySQL server on localhost as user <mysqluser> and selecting the database <mysqldb>. The mysql tool will prompt for <mysqluser>'s access password before executing the script.
As I mentioned in the post you referenced, you NEED to create the tables first.
Peek at the XML or the SQL output on what columns you need. e.g. here is a table that can hold the output from badges.xml (I don't have the others available right now..)
CREATE TABLE `badges` (
`Id` int(11) NOT NULL default '0',
`UserId` int(11) not NULL,
`Date` datetime not NULL,
`Name` varchar(32) not NULL,
PRIMARY KEY (`Id`),
KEY `Date` (`Date`),
KEY `UserId` (`UserId`)
) ;
Have you actually created the database 'personal' and the table 'posts'?
You might want to try something like:
mysql -h localhost -u <user> -p<password> -D personal < /users/cs/SO_db/posts.sql
Your posts.sql contains some statements referencing a posts table, which doesn't exist in your personal schema.
To "solve" the error, ensure the table is created!
probably your sql file doesn't include the "create table" command.