[转] 替Mysql添加远程访问权限
[转] 为Mysql添加远程访问权限 为Mysql添加远程访问权限 发表于 2009-07-26 01:22 AM 作者: z2 下面看看从网上搜集来的几种添加Mysql用户远程访问权限的方法 MySQL 上的一个数据库要备份,装了个MySQL的gui工具。打开"MySQL Administrator"工具,填好用户名和
[转] 为Mysql添加远程访问权限为Mysql添加远程访问权限
发表于 2009-07-26 01:22 AM 作者: z2
下面看看从网上搜集来的几种添加Mysql用户远程访问权限的方法
MySQL 上的一个数据库要备份,装了个MySQL的gui工具。打开"MySQL Administrator"工具,填好用户名和密码却登录不了,老是报这个错“ERROR 1130: Host 'lijuan-' is not allowed to connect to this MySQL server”。网上查了下,有这两个方法解决:
解决方法:
1。 改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%"
mysql -u root -pvmwaremysql>use mysql;mysql>update user set host = '%' where user = 'root';mysql>select host, user from user;
2. 授权法。例如,你想myuser使用mypassword从任何主机连接到mysql服务器的话。
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想允许用户myuser从ip为192.168.1.3的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
我 的mysql.user里root用户的host果然是localhost,先用改表法给localhost改成“%”,还是不行,仍然报1130的错 误,又按“从任何主机连接到mysql服务器”方法授权,还是报一样的错,最后给自己的ip授权之后,终于登录上了。。。。
乎乎。。。
mysql的ERROR 1045 在上面情况后如再出现客户段1045可在服务器执行如下
UPDATE user SET Password=PASSWORD('123456') where USER='myuser';
FLUSH PRIVILEGES;//用户付完权限后对数据进行刷新时用!要不Mysql数据库识别不了
例如:(必须参考以上再看下面的例子)
GRANT ALL ON *.* TO admin@'%' IDENTIFIED BY 'admin' WITH GRANT OPTION;
mysql "192.168.50.85" "admin" "admin" ;
GRANT ALL ON *.* TO admin@'localhost' IDENTIFIED BY 'admin' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.50.85' IDENTIFIED BY '123456' WITH GRANT OPTION;
UPDATE user SET Password=PASSWORD('123456') where USER='myuser';
FLUSH PRIVILEGES;
mysql默认是没有开启远程控制的,必须添加远程访问的用户。
mysql默认是没有开启远程控制的,必须添加远程访问的用户。 g&00 x$ Y
0VE }0(fQ
如果是安装版的话,从mysql提供的控制台进入。 1s+
用root用户登陆,然后: Q k C jgS0
grant all privileges on *.* to 创建的用户名 @"%" identified by "密码"; o! q*)`xuQ
flush privileges; * 刷新刚才的内容* )/ z (5 3X
; (Q:LY \v
格式:grant 权限 on 数据库名.表名 to 用户@登录主机 identified by "用户密码"; .=h j Qi[
@ 后面是访问mysql的客户端IP地址(或是 主机名) % 代表任意的客户端,如果填写 localhost 为本地访问(那此用户就不能远程访问该mysql数据库了)。 U lp 8 z Rc 同时也可以为现有的用户设置是否具有远程访问权限。如下: \ch3 X X# use mysql; o$`> :>N e update db set host = '%' where user = '用户名'; (如果写成 host=localhost 那此用户就不具有远程访问权限) B Gnl: R * FLUSH PRIVILEGES; zn 6en;&? 3 Pj_2B= 查看结果,执行: $4b 5-U use mysql; ){[' 66! select host,user,password from user; J):H\B:j_M i oZ 0 " H +--------------+--------+---------------+ t75 JSdQ | Host | User | Password | XKL Di{ U +--------------+--------+-----------------+ B*1Q
| localhost | | | U 8RZq(f | % | John | 123456 | r ` Al B | localhost | root | | H fd ZE +--------------+------ --+---------------+ pd7= 8 8 ArJ~Vs "+ 总结: ? Av L`B A 其实MySQL默认有两个数据库分别为 mysql 和 test 而MySQL用户的信息都放在数据库 mysql 的相关表中 gb: hj / 也可以使用 Navicat (推荐)这样的GUI工具来管理用户。 HUD?}U BB5 update user set host='%' where host='localhost' 工作中用到web服务器和mysql服务器不在同一台计算机上安装的运用。需要通过mysql的远程账户访问mysql。 先上语法: grant [权限] on [数据库名].[表命] to ['用户命']@['web服务器的ip地址'] identified by ['密码']; 实例: grant all on lportal.* to 'root'@'192.168.1.21 identified by 'root'; grant select,update,insert,delete on lportal.* to 'root'@'192.168.1.21 identified by 'root';

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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











Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

When developing an e-commerce website using Thelia, I encountered a tricky problem: MySQL mode is not set properly, causing some features to not function properly. After some exploration, I found a module called TheliaMySQLModesChecker, which is able to automatically fix the MySQL pattern required by Thelia, completely solving my troubles.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.
