MySQL allows remote access to settings
1. Note Bind-address = 127.0.0.1.
The code is as follows:
>sudo vim/etc/mysql/mysql.conf.d/mysqld.cnf
Comment out bind-address = 127.0.0.1 (that is, add # at the beginning of the line), as follows:
The code is as follows:
# Instead of skip-networking The default is now-listen only on
# localhost which are more compatible and are not less secure.
# bind-address = 127.0.0.1
In addition to watching this sentence, you can also change the IP address of the following to allow the connection of the IP address. However, if it is just a database for development purposes, it is recommended to comment directly for the sake of convenience.
As you can see from the comments above, the old version of MySQL (shown on some data as 5.0 and its previous version) is skip-networking. So, kindly remind me that using the old version of the small partner please note.
2. Delete anonymous users
Log into the database:
The code is as follows:
>mysql-uroot-p123456
Then, switch to MySQL database. SQL is as follows:
The code is as follows:
Use MySQL;
Then, delete the anonymous user. SQL is as follows:
The code is as follows:
Delete from user where user= ';
3. Increase the number of users that allow remote access or allow remote access for existing users.
Then, after deleting the anonymous user, give root all the permissions to access any database on any host (%). The SQL statements are as follows:
The code is as follows:
Mysql> Grant all privileges on * * to ' root ' @ '% ' identified by ' 123456 ' with GRANT option;
If you need to specify an access host, you can replace% with the host's IP or host name. In addition, this method adds a record to the database MySQL table user. If you do not want to add records, just want to modify an existing user (for example, root) to allow remote host access, you can use the following SQL to complete:
The code is as follows:
Update user set host= '% ' where user= ' root ' and host= ' localhost ';
4. Exit the database
The code is as follows:
Mysql> exit
After the MySQL shell executes the SQL, you need to exit to bash Execution System command and exit is required. Because this is too common and too simple. The following prompts "exit" and no longer lists this command again.
5. Restart the database
Once you have completed all of the above steps, you will need to restart the database for the modified configuration to take effect. Execute the following command to restart the database:
The code is as follows:
>sudo Service MySQL Restart
After deploying MySQL, unable to set user remote login (% only all users, not, can only give the specified IP?) )