Use tool to connect the linux mysql8.0

After the build environment LNMP connected Navicate / mysql Workbench Error

  First I encountered this problem on the server where treated with mysql connection

  1, the connection server: mysql -u root -p

  2, look at all the current databases: show databases;

  3, enter the mysql database: use mysql;

  4, to see all the tables in the mysql database: show tables;

  5, view the data in the user table: select Host, User, Password from user;

  6, modify the user table Host: update user set Host = '%' where User = 'root';

  7, the last refresh: flush privileges;

\ # We must remember that in the time to write sql statement after the completion of the words ";" The following is an illustration

  ! [Img] (https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005131022661-152795230.png)

  First I encountered this problem on the server where treated with mysql connection

  Connect to the server: mysql -u root -p

  ! [Img] (https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005131318255-683574509.png)

  View all current databases: show databases;

  ! [Img] (https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005131646286-1982836224.png)

  Enter the mysql database: use mysql;

  ! [Img] (https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005131749724-1387433844.png)

  View all mysql database tables: show tables;

  ! [Img] (https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005131937958-1048454413.png)

  View user of the table: select Host, User, Password from user;

  ! [Img] (https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005132311646-432223453.png)

  Modify the user table Host: update user set Host = '%' where User = 'root';

  ! [Img] (https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005132640099-1037311838.png)

  Last refresh: flush privileges;

  ! [Img] (https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005132739865-1075208564.png)

  Retest Navicate know about it:

  ! [Img] (https://images2017.cnblogs.com/blog/1241620/201710/1241620-20171005132842427-2119447116.png)

 

The first solution to the problem is:

Open ports in the iptables in 3306

\#/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT

\#/etc/rc.d/init.d/iptables save 保存:

\ # Service iptables restart to restart to take effect

\############################################################################################

iptables -I INPUT -p TCP -s 0.0.0.0/0 --dport 3306 -j ACCEPT // I used the command iptables open port in 3306

The second solution is:

Set up remote access:

// any remote host can access the database

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;

// need to enter the sub-command change to take effect

mysql> FLUSH PRIVILEGES;

//drop out

mysql> EXIT

The third is not explained.

(Another way to say shut down the server firewall: # service iptables stop does not recommend using this method will lead to unknown security issues)

Obviously not finally resolved, in a lot of online information are repeated, and finally there is no way to find help only to find that the brothers Ali cloud console side of the issue, indicating the direction of their thinking or wrong. Specific solutions Yes:

Open cloud server ECS

Open instance of the left menu

Open the rightmost instance management

Open the menu on the left of this example security group

Open the right configuration rules

The upper right corner to add the security group rules

The default custom protocol type, port range: 3306/3306, an authorization object: 0.0.0.0/0, other default on the line

After determining restart the server

Connections OK!

Guess you like

Origin www.cnblogs.com/guoyinghome/p/11199490.html