简体   繁体   中英

Can't login to MySQL Server externally

I have an Ubuntu 16.04 server running on Microsoft Azure, and I have a MySQL Server running on that. I have 2 users, root and MattyAB (Me), which I created with this command:

GRANT CREATE ON *.* To 'MattyAB'@'localhost' IDENTIFIED BY '********';
GRANT ALL PRIVILEGES ON * . * TO 'MattyAB'@'localhost';

Where * is my password. I then try to connect to the server with my personal computer, but it doesn't work.

What am I doing wrong? Do I need to change this @'localhost' to something else?

So I have ran into this problem with other things that I have done.

So you basically just need to run the following command after identifying what port your mySql runs on.

In Your Ubuntu Terminal. Run This

EXPOSE <PORT NO>

Try sudo expose if this does not work.

What have you done? You gave grants to access all databases and tables *.* at your server to the account

'MattyAB'@'localhost'.

Localhost obviously is not an extern account. As far as I know you have to use the '%' operator instead of 'localhost' , or just the IP from which you want to log on to your mysql server.

You need something like this: GRANT CREATE ON *.* TO 'MattyAB'@'%' IDENTIFIED BY '******'; I am not sure with the single quotes around the %. In case of error try both types of syntax. Furthermore you can take a look at MYSQL Grant Syntax .

With SHOW GRANTS FOR MattyAB you can check your grants configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM