当前位置:网站首页>Steps and FAQs of connecting windows Navicat to Alibaba cloud server MySQL

Steps and FAQs of connecting windows Navicat to Alibaba cloud server MySQL

2022-07-05 06:59:00 Silence, your name

Log in to your Alibaba cloud server first

 

 

 

  There are two more important , One is to configure the exit port ,

Another is to get your own public network ip  Connect to the server

I use it finalshell  Tool connection .

Mainly based on docker install mysql , Now my server docker Already installed , It's easy to install . There are many detailed steps on the Internet , Just run it once

Docker Configuration installation in MySQL_tuziailuobo_lee The blog of -CSDN Blog _docker install mysql To configure Time :2022-04-13 author :tuziailuobo brief introduction : stay Docker Install in MySQL And configure , Mount the data locally Docker Configuration installation in MySQL explain : It is installed by default docker, The environment is Alibaba cloud ubuntu20, Alibaba cloud security group is open 3306 port .1、 download MySQL Mirror image docker pull mysql:5.72、 establish MySQL The container mounts data at the same time docker run -d --restart=always --name mysql02 -p 3306:3306 -v /home/mysql.https://blog.csdn.net/qq_40716436/article/details/124149033?ops_request_misc=&request_id=&biz_id=102&utm_term=docker%E5%AE%89%E8%A3%85mysql&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-5-124149033.142^v30^pc_rank_34,185^v2^control&spm=1018.2226.3001.4187

 

I also wrote an article myself . But it doesn't matter  , It is important to pay attention to several points after installation

Look at the mirror image

docker images

But it doesn't matter whether you look or not , It will be pulled automatically anyway

Look at the container

docker ps

 

 

Follow the command and run again , Then check it out mysql Successful operation . If mysql Successfully run . Use navicat Connect

 

Okay , Half the water .  navicat  There are several common errors in connection

2005 - Unknown MySQL server host '45.130.63.101' (11001) "

This error should be reported by the server ip incorrect

2003 - Can't connect to MySQL server on '47.100.68.107' (10060 "Unknown error")

Maybe the port is not open

Remember to open the server port . This port is not necessarily 3306 . It's up to you to start docker Container time . Mapped port

But half of them are 3306 

 

 1045 - Access denied for user 'root'@'117.147.47.90' (using password: YES).

  After the port is opened , Change a wrong one .ip I'm too lazy to hide .  This port is more general . Maybe the account and password are wrong . It may also be that the account does not allow remote access .

# to update ,   Or install yum
        yum -y update

        # Clear the remaining items of the system if the server has not been installed before Docker, You can skip 
        yum remove docker \
        docker-client \
        docker-client-latest \
        docker-common \
        docker-latest \
        docker-latest-logrotate \
        docker-logrotate \
        docker-selinux \
        docker-engine-selinux \
        docker-engine

        # Installation package required 
        yum install -y yum-utils

        # Set up the warehouse for the image 
        yum-config-manager \
        --add-repo \
        https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

        # to update yum Package index 
        yum makecache fast

        # install docker dependent  docker-ce  Community Edition   and ee It's the enterprise edition 
        yum install docker-ce docker-ce-cli containerd.io

         start-up docker
        systemctl start docker

        # test 
        docker run hello-world
        12345678910111213141516171819202122232425262728293031323334353637
        #8. View the downloaded images ( From here, you can view the existing images id)
        [[email protected] ~]# docker images
        REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
        hello-world           latest              bf756fb1ae65        4 months ago      13.3kB

        # Create and enter relevant containers 
        mkdir ~/mysql
        cd ~/mysql

        # Configure Alibaba cloud image acceleration 
        http://oss.console.aliyun.com
         Console search container image service .  Image accelerator , Choose your own linux Version USES . Everyone's different 

        # docker  Download  mysql
        docker pull mysql

        # start-up 
        docker run -id \
        -p 3306:3306 \
        --name=mysql \
        -v $PWD/conf:/etc/mysql/conf.d \
        -v $PWD/logs:/logs \
        -v $PWD/data:/var/lib/mysql \
        -e MYSQL_ROOT_PASSWORD=a123..a \
        -d mysql

        # Into the container 
        docker exec -it mysql bash

        # Sign in mysql
        mysql -u root -p

        # modify root User password 
        ALTER USER 'root'@'localhost' IDENTIFIED BY 'a123..a';

        # Add remote login user ------- 8.0 After that ----------------
        #user_name: To create a user's name 
        #host: Indicates which machine the newly created user is allowed to log in from , If you are only allowed to log in from this machine , be   fill  ‘localhost’ , If remote login is allowed , Then fill in  ‘%’
        #password: Login database password of newly created user , If you don't have a password, don't write .
        CREATE USER 'silence'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
        #privileges: Say what power to grant , For example, there can be  select , insert ,delete,update etc. , If all power is to be granted , Then fill in  ALL
        #databasename.tablename: Indicates which table in which database the user's permission can be used , If you want the user's permissions to work on all tables in all databases , Then fill in  *.*,* It's a wildcard , All 
        #’username‘@‘host’: Indicates which user is authorized .
        GRANT ALL PRIVILEGES ON *.* TO 'silence'@'%';

        # Add remote login user ------- 8.0 Previous 
        # first root Represents the user name ,% All computers can be connected , You can also set a ip Address run connection , the second root The password 
        GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

        # Refresh MySQL System authority related table of 
        flush privileges;


        # View all users ( user name 、 Who is authorized to )
        SELECT user,host FROM mysql.user;

docker exec  mysql01 bash

Enter the container first . Remember to change the name of your container . Specified when creating containers

  Sign in mysql

 Welcome to the MySQL monitor.  See this to prove the account password , That's all right. . If navicat  I logged in with this account and password , Still there 1045 . That is the problem of account authorization .

# Add remote login user ------- 8.0 Previous 
# first root Represents the user name ,% All computers can be connected , You can also set a ip Address run connection , the second root The password 
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

# Refresh MySQL System authority related table of 
flush privileges;


# View all users ( user name 、 Who is authorized to )
SELECT user,host FROM mysql.user;

I used to give root Account authorized , But it still seems 1045 . no way

 SELECT user,host FROM mysql.user;

It may be the reason why I didn't do well . Later, I created another user silence . Can successfully access .

Let me create another account .

A lot of things , In fact, it is to create users , Authorize remote access . My username here is silence1

CREATE USER 'silence1'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

 GRANT ALL PRIVILEGES ON *.* TO 'silence1'@'%';

 

 

Okay . Connected

原网站

版权声明
本文为[Silence, your name]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050656546540.html