MySQL Create a user that can only access a specific database, why can't I connect remotely?

Viewed 34

I have remote access to root user.

The statement to create the user is as follows:

CREATE USER 'auser'@'%' IDENTIFIED BY 'auser';
GRANT ALL ON `MyDB`.* TO 'auser'@'%';
flush privileges;

This auser account cannot log in remotely, what is the reason?

PS. Use navicat to log in to the database prompt: 2013 - Lost connection to MySQL server during query

1 Answers

I login the user on Linux, mysql prompt init_connect command failed after execute USE DatabaseName .

I found the answer online. Change /etc/my.cnf from

init_connect=‘SET collation_connection = utf8_unicode_ci’
init_connect=‘SET NAMES utf8’

to

init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'

Note the single quotes.

Then restart mysql, the problem is solved.

Related