After you install MySQL, you want to use another computer for remote login, you are prompted to reject the connection at logon
After Baidu, found that need two steps to solve the problem
- Modify bind_address = 0.0.0.0 in/etc/mysql/my.cnf
(1)直接授权
Mysql>grant all privileges on * * to ' root ' @ '% ' identified by ' 123456 ' with GRANT option;mysql>flush rivileges
(2)改表法 可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改成”%”
Mysql-u root-p passwd mysql>use mysql;mysql>update user Set host = '% ' where user = ' root '; Mysql>select host, U Ser from user;
But in the first step, the content of MY.CNF is the following:
# # The MySQL database server configuration file.## You can copy this to one of:#-'/etc/mysql/my.cnf ' to set global Optio ns,#-"~/.my.cnf" to set user-specific options.# # One can use all long options, the program supports.# Run program W ITH--help to get a list of available options and with#--print-defaults to see which it would actually understand and use . # # for explanations see# http://dev.mysql.com/doc/mysql/en/server-system-variables.html # # * important:additional Settings that can override those from this file!# the files must end with '. Cnf ', otherwise they ' ll be ignored.#!inclu dedir/etc/mysql/conf.d/!includedir/etc/mysql/mysql.conf.d/
Finally found that the need to modify is /etc/mysql/mysql.conf.d/mysqld.cnf
using sudo Vim /Etc/mysql/mysql.conf.d/mysqld.cnf
then restarting the MySQL service is available: sudo/etc/init.d/mysql restart
An issue where only local connections cannot be connected remotely after MySQL server is installed on Ubuntu