Linux 设置远程连接,并添加远程连接用户(10038)

1:配置mysql服务器

# 1.更改配置文件

#因为远程mysql服务器,设置只监听本地的端口,更改mysql配置文件,注释掉下面的一行。打开远程服务器的配置文件.

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf # 注释下面一行。
# bind-address = 127.0.0.1
# 如果没注释上面的一行,客户端连接时,会出现如下错误。
ERROR 2003 (HY000): Can't connect to MySQLserver on '192.168.1.249' (111)

# 2. 打开mysql服务

sudo service /etc/init.d/mysql start

# 3. 配置mysql服务器

qt@tony:~/Desktop$ mysql -u root -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is36
Server version: 5.5.53-0ubuntu0.12.04.1 (Ubuntu)
<!-- wp:paragraph -->
<p>Copyright (c) 2000, 2016, Oracle and/or its affiliates. All
rights reserved.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Oracle is a registered trademark
of Oracle
Corporation and/or its<br>
affiliates. Other names may be trademarks of their respective<br>
owners.</p>
<!-- /wp:paragraph -->
Type 'help;' or 'h' for help. Type 'c' to clear the currentinput statement.
mysql> use mysql;
Reading table information for completion of table and column names
You can turn offthis feature to get a quicker startup with -A
Database changed

# 允许用户的ip是192.168.1.248,使用用户名为 saiita, 密码是 password进行登录。

mysql> grant all PRIVILEGES on *.* to saiita@'192.168.1.248' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye

2:Mysql添加远程连接用户

# 连接出现错误。
# error1:
ERROR 1045 (28000): Access denied for user 'saiita'@'aplex-2.local' (using password: YES)
# 我这边得情况是本地的ip没有配置,从新配置ip.
sudo ifconfig eth0 192.168.1.248.
# 连接
# 以服务器设置的用户名登录
Qt@tony:~$ mysql -h 192.168.1.248 -u saiita -p
Enter password: 
# 或者以root用户登录
Qt@tony:~$ mysql -h 192.168.1.249 -u saiita -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 37
Server version: 5.5.53-0ubuntu0.12.04.1 (Ubuntu)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>



知识共享许可协议本作品采用知识共享署名-相同方式共享 4.0 国际许可协议进行许可。

相关推荐

Ubuntu 开启cron日志

✅ 1、打开终端。 ✅ 2、编辑 rsyslog 配置文件以将 cron 记录发送到指定文件。 你可以使用你喜 ...

暂无评论

目录展开