数据库
首页 > 数据库> > Linux-Ubuntu-18.04-字符界面-MySQL安装、配置与使用

Linux-Ubuntu-18.04-字符界面-MySQL安装、配置与使用

作者:互联网

前言

个人笔记,用于记录

MySQL

安装

	# 安装
	sudo apt-get install mysql-server
	# 初始化配置
	sudo mysql_secure_installation

服务启动关闭状态

  1. 状态
	service mysql status
  1. 启动/重启
	service mysql start/restart
  1. 关闭
	 service mysql stop

修改配置

  1. 连接,输入MySQL
  2. 端口
	netstat -an|grep 3306
	vim /etc/mysql/mysql.conf.d/mysqld.cnf
  1. plugin
    在这里插入图片描述
	update user set plugin='mysql_native_password' where user='root';
	flush privileges;
  1. authentication_string
	update user set authentication_string=password('root') where user='root';
	flush privileges;
  1. 查看root用户的访问IP
	user mysql;
	select user,host from user where user='root';

在这里插入图片描述
6. 将其修改为任意IP可以访问,%

	use mysql;
	update user set host='%' where user='root' and host='localhost';

在这里插入图片描述
7. 下面是授予权限,如果出现其他主机无法连接的情况

	grant all privileges on *.* to root@'%' identified by 'root' with grant option;quit
	flush privileges;

在这里插入图片描述

8.0.x mysql 版本

  1. 问题full_group_by
	# 解决方式
	cd /etc/mysql/mysql.conf.d
	vim mysqld.cnf
	在文件的【mysqld】下面加上一行,或者去掉已有的sql_mode=only_full_group_by
	改为
	sql_mode=
STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

标签:18.04,Linux,where,privileges,Ubuntu,NO,user,mysql,root
来源: https://blog.csdn.net/weixin_43892404/article/details/108585913