久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

ubuntu server配置mysql并實(shí)現(xiàn)遠(yuǎn)程連接的操作方法

176次閱讀
沒有評論

共計(jì) 3405 個(gè)字符,預(yù)計(jì)需要花費(fèi) 9 分鐘才能閱讀完成。

自動(dòng)寫代碼機(jī)器人,免費(fèi)開通

服務(wù)器:ubuntu server 16.04 LSS

客戶機(jī):ubuntu 16.04 LTS

服務(wù)器配置

服務(wù)器安裝 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 mysql
tcp 0 0 localhost:mysql *:* LISTEN 5287/mysqld

修改遠(yuǎn)程連接配置文件

# 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

設(shè)置服務(wù)器數(shù)據(jù)庫字符為 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 = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
character-set-server=utf8 #新增加
#登錄 mysql 查看字符
# eric @ userver in ~ [14:21:26]
$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server 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 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 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)

新建遠(yuǎn)程登錄用戶并授權(quán)

mysql create user 'eric'@'%' identified by 'lyd2017';
Query OK, 0 rows affected (0.01 sec)
mysql grant all on *.* to 'eric'@'%';-- 所有權(quán)限
Query OK, 0 rows affected (0.00 sec)

關(guān)于授權(quán):

命令:GRANT privileges ON databasename.tablename TO ‘username’@’host’

說明:privileges- 用戶的操作權(quán)限,如 select,insert,update 等,如果要授予所有權(quán)則使用 all

如果要授予該用戶對所有數(shù)據(jù)庫和表的操作權(quán)限則用 * 表示,如 *.*

例如:

GRANT SELECT, INSERT ON mysql.tables TO 'eric'@'%';
GRANT ALL ON *.* TO 'eric'@'%';

但是用這些命令授權(quán)的用戶不能再給其他用戶授權(quán),如果要讓該用戶有權(quán)限,則使用

GRANT privileges ON databasename.tablename TO 'username'@'host' WITH GRANT OPTION;

重啟服務(wù)器

# 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 服務(wù)器

# 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 15
Server 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 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

關(guān)于直接用 root 用戶連接報(bào)錯(cuò)問題

# eric @ ray in ~ [14:35:22] C:1
$ mysql -h 192.168.122.58 -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'192.168.122.1' (using password: YES)
#如果剛開始,直接用 root 用戶登錄,則會(huì)報(bào)錯(cuò),可修改 root 密碼解決該問題
mysql SET PASSWORD FOR 'root'@'%' = PASSWORD("123456");

以上這篇 ubuntu server 配置 mysql 并實(shí)現(xiàn)遠(yuǎn)程連接的操作方法就是丸趣 TV 小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持丸趣 TV。

向 AI 問一下細(xì)節(jié)

丸趣 TV 網(wǎng) – 提供最優(yōu)質(zhì)的資源集合!

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-12-18發(fā)表,共計(jì)3405字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 奈曼旗| 遂川县| 丽水市| 黄梅县| 崇仁县| 若羌县| 乡宁县| 襄汾县| 高雄县| 昂仁县| 朔州市| 宽城| 当阳市| 上林县| 攀枝花市| 郧西县| 延川县| 隆化县| 宁武县| 丁青县| 黑山县| 灌云县| 观塘区| 济阳县| 祥云县| 泰顺县| 霍邱县| 师宗县| 申扎县| 山丹县| 比如县| 谷城县| 株洲市| 郁南县| 华亭县| 图们市| 迁安市| 搜索| 榕江县| 思南县| 达日县|