时间:2021-05-23
服务器:ubuntu server 16.04 LSS
客户机:ubuntu 16.04 LTS
服务器配置
服务器安装mysql
# eric @ userver in ~ [14:00:31] $ sudo apt install mysql-server install mysql-client libmysqlclient-dev检查是否成功SET PASSWORD FOR ‘pig'@'%' = PASSWORD(“123456”);
# eric @ userver in ~ [14:10:55] $ sudo netstat -tap | grep mysqltcp 0 0 localhost:mysql *:* LISTEN 5287/mysqld修改远程连接配置文件
# eric @ userver in ~ [14:16:26] $ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf #注释掉 bind-address = 127.0.0.1#bind-address = 127.0.0.1设置服务器数据库字符为utf-8
# eric @ userver in ~ [14:16:26] $ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf #在[mysqld] 中添加:character-set-server=utf8[mysqld]## * Basic Settings#user = mysqlpid-file = /var/run/mysqld/mysqld.pidsocket = /var/run/mysqld/mysqld.sockport = 3306basedir = /usrdatadir = /var/lib/mysqltmpdir = /tmplc-messages-dir = /usr/share/mysqlskip-external-lockingcharacter-set-server=utf8 #新增加#登录mysql查看字符# eric @ userver in ~ [14:21:26]$ mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show variables like '%char%';+--------------------------+----------------------------+| Variable_name | Value |+--------------------------+----------------------------+| character_set_client | utf8 || character_set_connection | utf8 || character_set_database | utf8 || character_set_filesystem | binary || character_set_results | utf8 || character_set_server | utf8 || character_set_system | utf8 || character_sets_dir | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.00 sec)新建远程登录用户并授权
mysql> create user 'eric'@'%' identified by 'lyd2017';Query OK, 0 rows affected (0.01 sec)mysql> grant all on *.* to 'eric'@'%';--所有权限Query OK, 0 rows affected (0.00 sec)关于授权:
命令:GRANT privileges ON databasename.tablename TO 'username'@'host'
说明:privileges-用户的操作权限,如select,insert,update 等,如果要授予所有权则使用all
如果要授予该用户对所有数据库和表的操作权限则用* 表示,如 *.*
例如:
GRANT SELECT, INSERT ON mysql.tables TO 'eric'@'%';GRANT ALL ON *.* TO 'eric'@'%';但是用这些命令授权的用户不能再给其他用户授权,如果要让该用户有权限,则使用
GRANT privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION;重启服务器
# eric @ userver in ~ [14:35:49] $ /etc/init.d/mysql restart [....] Restarting mysql (via systemctl): mysql.service==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===Authentication is required to restart 'mysql.service'.Authenticating as: eric,,, (eric)Password: ==== AUTHENTICATION COMPLETE ===客户端
安装mysql客户端
# eric @ ray in ~ [14:32:12] C:127$ sudo apt install mysql-client[sudo] password for eric: Reading package lists... Done连接mysql服务器
# eric @ ray in ~ [14:37:13] C:1$ mysql -h 192.168.122.58 -u eric -p #Enter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 15Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>关于直接用root用户连接报错问题
# eric @ ray in ~ [14:35:22] C:1$ mysql -h 192.168.122.58 -u root -pEnter password: ERROR 1045 (28000): Access denied for user 'root'@'192.168.122.1' (using password: YES)#如果刚开始,直接用root用户登录,则会报错,可修改root密码解决该问题mysql>SET PASSWORD FOR 'root'@'%' = PASSWORD("123456");以上这篇ubuntu server配置mysql并实现远程连接的操作方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
Mysql远程连接配置实现的两种方法大家在公司工作中,经常会遇到mysql数据库存储于某个人的电脑上,大家要想连接mysql服务,装有mysql服务的电脑就必须
Ubuntu默认并没有安装ssh服务,如果通过ssh远程连接到Ubuntu,需要自己手动安装ssh-server。判断是否安装ssh服务,可以通过如下命令进行:
前言本文主要跟大家分享了关于Ubuntu18.04配置mysql及配置远程连接的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧配置教程
第一中方法:比较详细以下的文章主要介绍的是MySQL数据库开启远程连接的时机操作流程,其实开启MySQL数据库远程连接的实际操作步骤并不难,知识方法对错而已,今
安装1、先安装vscode,然后在扩展中搜索RemoteSSH插件并安装。2、我要连接远程Ubuntu系统的服务器,所以需要在服务器上安装ssh并配置:Q