MySQL connected to remote Ubuntu server

Install mysql

# Check whether MySQL is installed:
dpkg -l | grep mysql
# Completely uninstall mysql see https://www.cnblogs.com/mjhblog/p/10499772.html
# Enter the topic: Install MySQL:
apt install mysql-server
# Check whether mysql is installed, see the following instructions, you are installed
root@huaweiyun:~# root@huaweiyun:~# service mysql restart
root@huaweiyun:~# netstat -tap | grep mysql
tcp6       00[::]:mysql              [::]:*                  LISTEN      1466/mysqld
tcp6       00 huaweiyun:mysql         113.45.85.95:56178      ESTABLISHED 1466/mysqld
root@huaweiyun:~# dpkg -l | grep mysql
ii  mysql-client-5.75.7.28-0ubuntu0.18.04.4           amd64        MySQL database client binaries
ii  mysql-client-core-5.75.7.28-0ubuntu0.18.04.4           amd64        MySQL database core client binaries
ii  mysql-common                          5.8+1.0.4                         all          MySQL database common files, e.g./etc/mysql/my.cnf
ii  mysql-server                          5.7.28-0ubuntu0.18.04.4           all          MySQL database server(metapackage depending on the latest version)
ii  mysql-server-5.75.7.28-0ubuntu0.18.04.4           amd64        MySQL database server binaries and system database setup
ii  mysql-server-core-5.75.7.28-0ubuntu0.18.04.4           amd64        MySQL database server binaries

Enter MySQL

mysql -u root -p

change Password##

# Stop MySQL
sudo /etc/init.d/mysql stop
# Create mysqld file
sudo mkdir -p /var/run/mysqld
# Assign permissions to the mysqld file
sudo chown mysql:mysql /var/run/mysqld
# Enter safe mode
sudo /usr/bin/mysqld_safe --skip-grant-tables --skip-networking &
#############
root@huaweiyun:~# 2019-11-23T12:05:41.538762Z mysqld_safe Logging to syslog.2019-11-23T12:05:41.541303Z mysqld_safe Logging to '/var/log/mysql/error.log'.2019-11-23T12:05:41.557945Z mysqld_safe A mysqld process already exists
             # There is nothing here by default, then enter mysql-u -p
# Not surprisingly, you will enter mysql
# Use mysql
use mysql;
# Set new password
update user set authentication_string=PASSWORD("New password") where User='root';
# Update system cache password
update user set plugin="mysql_native_password";
# Refresh operation permissions
flush privileges;
# enter\q Exit the mysql shell, then you can log in to your database with the new password

Set to allow remote login##

# Enter the new password to enter the database
mysql -u root -p
# Use mysql database
use mysql;
# Modify remote login permissions
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
# Refresh operation permissions
flush privileges;
# enter\q exit mysql

Change configuration file##

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
# Comment below command
bind-address =127.0.0.1
# Must comment this sentence Must comment this sentence Must comment this sentence

Set the database to start automatically

systemctl enable mysql.service

Development designated port##

# Install iptables, many are already installed by default, you don’t need to install it
sudo apt-get install iptables
# Release the designated port, here I release 3306
iptables -I INPUT -p tcp --dport 3306-j ACCEPT
# Save rules
iptables-save
# Install iptables-persistent guarantees that the rules will not be cleared the next time you boot
sudo apt-get install iptables-persistent
# Set persistence rules
sudo netfilter-persistent save
sudo netfilter-persistent reload

Open the security group and set the incoming direction rule##

Here I purchased a Huawei Cloud server. Find the inbound rule of your server’s security group. You can choose to release it with one click or release 3306 quickly, and then you can use tools to connect to your database.

Security group entry rules.png

Open the cmd test and find that the connection is successful

win10 test.png

Recommended Posts

MySQL connected to remote Ubuntu server
Remote connection to Ubuntu 19.1
How to enable Mysql remote access under Ubuntu 14.04
How to install MySQL on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install mysql in Ubuntu 14.04
How to install mysql in Ubuntu 14.04
How to install MySQL on Ubuntu 14.04
Windows remote connection to Ubuntu 16.4 desktop
How to install Bacula Server on Ubuntu 14.04
How to install MySQL on Ubuntu 18.04 (linux)
How to use Samba server on Ubuntu 16.04
How to change MySQL password under Ubuntu
How to install Zabbix on Ubuntu 16.04 Server
Ubuntu14 upgrade MySQL
How to use Prometheus to monitor your Ubuntu 14.04 server
How to install Squid proxy server on Ubuntu 18.04
How to set up Shiny Server on Ubuntu 14.04
How to set static IP on Ubuntu 18.04 Server
How to set static IP on Ubuntu 18.04 Server
How to install python in ubuntu server environment
How to quickly deploy docker on ubuntu server
Remotely connect to MySQL database in Ubuntu environment
How to run the parsing server on Ubuntu 14.04
How to install the latest MySQL on Ubuntu 18.04
How to set up a DNS server on Ubuntu 18.04
Ubuntu ssh-keygen remote login
How to upgrade to Ubuntu 20.04
How to install and use MySQL Workbench on Ubuntu 18.04
Install mysql on Ubuntu 14.04
Ubuntu19 install MySQL pit
Ubuntu completely remove MySQL
ubuntu remote connection 22 port
Install MySQL under Ubuntu
ubuntu install nginx server
How to upgrade to Ubuntu 20.04
How to open https on nginx server under Ubuntu
Teach you how to build a Git server on Ubuntu
How to build an NFS file sharing server on Ubuntu 16.04
How to install JDK and Mysql on Ubuntu 18.04 linux system
[Quick Start] How to install Apache web server on Ubuntu 18.04
[Linux] Build Samba server (ubuntu16.04)
Install OpenSSL 1.0.2 on Ubuntu Server 14.04
Ubuntu Server Chapter 8 DNS Service
ubuntu 16.04 build pptpd V** server
Ubuntu Server Chapter 3 Package Management
Ubuntu completely uninstall mysql turn
Upgrade Ubuntu 18.04 on Azure to 18.10
Configure tomcat on ubuntu server
Server upgrade Ubuntu 20.04 LTS record
ubuntu 16.10 supports ssh remote access
Build Ubuntu 12.04 cross compilation server
Install Mysql offline on Ubuntu
ubuntu7.10 installed to 3D open
Server upgrade Ubuntu 20.04 LTS record
Ubuntu server builds Java web server
Use virtualbox to deploy ubuntu
Ubuntu deploys squid proxy server
Initial setup of Ubuntu 16.04 server
Ubuntu16.04 build GitLab server tutorial
How to upgrade to Ubuntu 16.04 LTS