【linux】【mysql】mysql8.0开启远程访问及常见问题
1.连接数据库
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 8.0.17 MySQL Community Server - GPL Copyright (c) 2000, 2019, 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>
2.在mysql8版本中更改用户密码需要加入with mysql_native_password
mysql> alter user 'root'@'localhost' identified with mysql_native_password by '***
';
Query OK, 0 rows affected (0.04 sec)
3.修改root用户的host为‘%’
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec) mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
4 rows in set (0.00 sec) mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
再查看root用户的host
mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| root | % |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
+------------------+-----------+
4 rows in set (0.01 sec)
至此,root用户的远程访问已开启。
4.测试下navicat连接
连接成功!
常见问题解决
1.解决sql_mode=only_full_group_by问题
[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'mingbyte.u.USER_ID' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
连接数据库,通过 select version(), @@sql_mode; 查看mode
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 89
Server version: 8.0.17 MySQL Community Server - GPL Copyright (c) 2000, 2019, 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> select version(), @@sql_mode;
+-----------+-----------------------------------------------------------------------------------------------------------------------+
| version() | @@sql_mode |
+-----------+-----------------------------------------------------------------------------------------------------------------------+
| 8.0.17 | ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+-----------+-----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec) mysql>
发现上文中查看的mode中有ONLY_FULL_GROUP_BY。将其删除
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
修改mysql的配置文件,重启依旧生效
- vi /etc/my.cnf
将上述sql_mode插入[mysqld]下方,保存,重启数据库,问题解决。
或者
mysql> set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected (0.01 sec) mysql> set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected (0.00 sec)
问题解决。
【linux】【mysql】mysql8.0开启远程访问及常见问题的更多相关文章
- Linux安装Mysql8.0及SQL分类的补充
Linux安装Mysql8.0 参考文章:https://blog.csdn.net/qq_38570633/article/details/109257430 参考文献:https://blog.c ...
- 【转】mysql给root开启远程访问权限,修改root密码
好记性不如烂笔头,偶然用一直忘.... mysql给root开启远程访问权限,修改root密码 1.MySql-Server 出于安全方面考虑只允许本机(localhost, 127.0.0.1) ...
- Centos7 安装mysql服务器并开启远程访问功能
大二的暑假,波波老师送了一个华为云的服务器给我作测试用,这是我程序员生涯里第一次以root身份拥有一台真实的云服务器 而之前学习的linux知识在这时也派上了用场,自己的物理机用的是ubuntu系统, ...
- linux安装mysql8.0及开启远程访问
第一步:获取mysql8.0的yum源 进入mysql官网获取RPM包下载地址 https://dev.mysql.com/downloads/repo/yum/ 点击下载后, 右键复制链接地 ...
- linux 安装mysql8.0
linux下安装mysql8.0 下载mysql $ wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-8.0/mysql-8.0.4 ...
- ubuntu16.04下安装mysql,并开启远程访问
一.安装 apt-get install mysql-server 二.本地连接 mysql默认开启了本地连接 直接通过mysql -uuser -p,然后输入密码访问 三.开启远程访问 3.1.创建 ...
- 安装MySQL数据库并开启远程访问
一.安装MySQL数据库 MySQL安装在系统盘下(C:\Program Files),方便系统备份. 1.双击安装程序,勾选“I accept the license terms”,点击“Next” ...
- Linux安装Mysql8.0.20并配置主从复制(一主一从,双主双从)
1. 主从复制解释 将主数据库的增删改查等操作记录到二进制日志文件中,从库接收主库日志文件,根据最后一次更新的起始位置,同步复制到从数据库中,使得主从数据库保持一致. 2. 主从复制的作用 高可用 ...
- linux安装mysql8.0
linux 上安装mysql8.0 mysql版本8.0.16 MySQL Community 操作系统centos7 准备工作: mysql8.0 rpm文件 安装步骤: 1. 下载mysql的re ...
随机推荐
- Java中synchronized关键字你知道多少
1.什么是synchronized 我们将其理解为同步锁,可以实现共享资源的同步访问,解决线程并发的安全问题.synchronize翻译成中文:同步,使同步.synchronized:已同步. 1.1 ...
- Unity进阶:行为树 02 夺旗战搭建场景,AI脚本,旗子拿起
版权申明: 本文原创首发于以下网站: 博客园『优梦创客』的空间:https://www.cnblogs.com/raymondking123 优梦创客的官方博客:https://91make.top ...
- react native Android支持gif和WebP动图
在项目android/app/build.gradle的文件中找到dependencies 支持gif动图加入: implementation 'com.facebook.fresco:animate ...
- Unity/C#基础复习(5) 之 浅析观察者、中介者模式在游戏中的应用与delegate原理
参考资料 [1] <Unity 3D脚本编程 使用C#语言开发跨平台游戏>陈嘉栋著 [2] @张子阳[C#中的委托和事件 - Part.1] http://www.tracefact.ne ...
- Unity进阶:用AssetBundle和Json做了一个玩家登陆界面
版权申明: 本文原创首发于以下网站: 博客园『优梦创客』的空间:https://www.cnblogs.com/raymondking123 优梦创客的官方博客:https://91make.top ...
- Java多线程之线程的暂停
Java多线程之线程的暂停 下面该稍微休息一下了呢……不过,这里说的是线程休息,不是我们哦.本节将介绍一下让线程暂停运行的方法. 线程Thread 类中的sleep 方法能够暂停线程运行,Sleep ...
- effective java 3th item1:考虑静态工厂方法代替构造器
传统的方式获取一个类的实例,是通过提供一个 public 构造器.这里有技巧,每一个程序员应该记住.一个类可以对外提供一个 public 的 静态工厂方法 ,该方法只是一个朴素的静态方法,不需要有太多 ...
- H5调用相机和相册更换头像
需求:H5调用手机的相机和相册从而实现更换头像的功能 这个功能是很常用的一个功能,因此做一个记录. 1.在头像img下加一个文件输入框 <input type="file" ...
- spss分析存在共性线后,接下来是怎么分析?
在进行线性回归分析时,容易出现自变量(解释变量)之间彼此相关,这种情况被称作多重共线性问题. 适度的多重共线性不成问题,但当出现严重共线性问题时,可能导致分析结果不稳定,出现回归系数的符号与实际情况完 ...
- HDU - 1392 Surround the Trees (凸包)
Surround the Trees:http://acm.hdu.edu.cn/showproblem.php?pid=1392 题意: 在给定点中找到凸包,计算这个凸包的周长. 思路: 这道题找出 ...