MySQL数据库如何开启远程连接(多备份)_MySQL
开启 MySQL 的远程登陆帐号需要注意下面3点:
1、确定服务器上的防火墙没有阻止 3306 端口。
MySQL 默认的端口是 3306 ,需要确定防火墙没有阻止 3306 端口,否则远程是无法通过 3306 端口连接到 MySQL 的。
如果您在安装 MySQL 时指定了其他端口,请在防火墙中开启您指定的 MySQL 使用的端口号。
如果不知道怎样设置您的服务器上的防火墙,请向您的服务器管理员咨询。
2.确定安全狗等没有拦截我们的备份服务器IP
如果你的服务器上有安装安全狗等安全类软件,请将我们的备份服务器IP 115.28.36.60以及其他的备份服务器IP添加到白名单中。
3、增加允许远程连接 MySQL 用户并授权。
1)登陆服务器端,进入命令行。
Windows 主机中是点击开始菜单,运行,输入“cmd”,进入命令行。
2)以数据库管理员帐号进入mysql控制台。在命令行执行 mysql -u root -p 密码,输入完成后即可进入mysql控制台。
例如: MySQL -uroot -p123456
123456 为 root 用户的密码。
3)创建远程登陆用户并授权,在控制台继续执行下面语句。
grant select,lock tables on demodb.* to demouser@'115.28.36.60′ identified by 'your password';
解释:demodb=数据库名;demouser=数据库用户名;your password=数据库密码
例如:
grant select,lock tables on discuz.* to ted@'115.28.36.60′ identified by '123456′;
4)执行了上面的语句后,再执行下面的语句,方可立即生效。
flush privileges;
小编解释:
grant select,lock tables on discuz.* to ted@'115.28.36.60′ identified by '123456′;
上面的语句表示将 discuz 数据库的select,locked权限授权给 ted 这个用户,允许 ted 用户在 115.28.36.60 这个 IP 进行远程登陆,并设置 ted 用户的密码为 123456 。
discuz.* 表示上面的权限是针对于哪个表的,discuz 指的是数据库,后面的 * 表示对于所有的表,由此可以推理出:对于全部数据库的全部表授权为“*.*”,对于某一数据库的全部表授权为“数据库名.*”,对于某一数据库的某一表授 权为“数据库名.表名”。
ted 表示你要给哪个用户授权,这个用户可以是存在的用户,也可以是不存在的用户。
115.28.36.60 表示允许远程连接的 IP 地址,如果想不限制链接的 IP 则设置为“%”即可。
注意:
115.28.36.60是我们的一个备份服务器IP,主要用来测试我们的服务器是否能够连接上你的数据库。
这里很多朋友会有疑问,这样会不会不安全啊,其实不用担心,因为首先,你只是授权允许我们的服务器连接你的数据库,其次,我们的服务器也只具有select和lock权限,也就是查询和锁表的权限,所以完全不能更改你的数据库。
不放心的话可以在mysql控制台执行 select host, user from user; 检查一下用户表里的内容.因为开启mysql远程登录的用户都是存储在mysql数据库中的user表中。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

Effective monitoring of Redis databases is critical to maintaining optimal performance, identifying potential bottlenecks, and ensuring overall system reliability. Redis Exporter Service is a powerful utility designed to monitor Redis databases using Prometheus. This tutorial will guide you through the complete setup and configuration of Redis Exporter Service, ensuring you seamlessly build monitoring solutions. By studying this tutorial, you will achieve fully operational monitoring settings
