一、下载MySQL压缩包后的安装步骤

  1. 将压缩包解压到指定的目录
  2. 编辑好配置文件
[mysql]
#设置MySQL客户端默认字符集
default-character-set=utf8 [mysqld]
#设置3306端口
port = 3306 #设置MySQL的安装目录
basedir =D:\Program Files\MySQL\mysql-8.0.22-winx64 #设置MySQL数据库的数据的存放目录
datadir = D:\Program Files\MySQL\mysql-8.0.22-winx64\data #允许最大连接数
max_connections=20 #服务端使用字符集默认为8比特编码的latin1字符集
character-set-server=utf8 #创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
  • DOS窗口下输入安装命令
  • ①进入到MySQL的bin目录下,或者配置好环境变量即可,任意路径可操作
    输入命令:mysqld install
	C:\WINDOWS\system32>mysqld install
The service already exists!
The current server installed:
  • 注释:提示该服务已存在,先卸载,命令:mysqld remove
	C:\WINDOWS\system32>mysqld remove
Service successfully removed.
  • ②继续安装
	C:\WINDOWS\system32>mysqld install
Service successfully installed.
  • 注释:提示安装成功
  • ③根据配置文件进行初始化命令:mysqld --initialize-insecure
	C:\WINDOWS\system32>mysqld --initialize-insecure
  • ④启动MySQL服务,命令:net start mysql
	C:\WINDOWS\system32>net start mysql
MySQL 服务正在启动 ..
MySQL 服务已经启动成功。
  • ⑤进入MySQL,root账号免密进入,命令:mysql -u root
C:\WINDOWS\system32>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.22 MySQL Community Server - GPL Copyright (c) 2000, 2020, 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>
  • ⑥查看MySQL有几个数据库,起始有4个才正常,查看命令;mysql> show databases;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)

二、DOS命令更改MySQL的root用户的密码

  1. 进入mysql库命令:use mysql; 查看表命令:show tables;
	mysql> use mysql;
Database changed
mysql> show tables;
+----------------------------------------------+
| Tables_in_mysql |
+----------------------------------------------+
| columns_priv |
| component |
| db |
| default_roles |
| engine_cost |
| func |
| general_log |
| global_grants |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| password_history |
| plugin |
| procs_priv |
| proxies_priv |
| replication_asynchronous_connection_failover |
| role_edges |
| server_cost |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+----------------------------------------------+
34 rows in set (0.00 sec)

2.user表中管理用户名与密码因此我们在这张表里面去修改,命令:
alter user ‘root’ @‘localhost’ identified by ‘123456’;

mysql> alter user 'root' @'localhost' identified by '123456';
Query OK, 0 rows affected (0.15 sec)

3.改完记得重新加载权限表,命令:flush privileges;

mysql> flush privileges;
Query OK, 0 rows affected (0.08 sec)

4.退出mysql重进,命令:mysql -u root

C:\WINDOWS\system32>mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
  • 注释:此刻没有密码是进不去的,证明我们改密成功了

5.输入命令:mysql -u root -p

C:\WINDOWS\system32>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.22 MySQL Community Server - GPL Copyright (c) 2000, 2020, 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>
  • 注释:输入密码成功进入

三、如何使用工具端Navicat连接数据库

  1. 打开客户端工具,输入相关的信息,点击测试连接

  • 注释:提示上述错误,是一个关于加密规则的错误:

很多用户在使用Navicat Premium 12连接MySQL数据库时会出现Authentication plugin ‘caching_sha2_password’ cannot be loaded的错误。出现这个原因是mysql 8 之前的版本中加密规则是mysql_native_password,而在mysql 8之后,加密规则是caching_sha2_password, 解决问题方法有两种,一种是升级navicat驱动,一种是把mysql用户登录密码加密规则还原成mysql_native_password.

  1. 进入mysql库,在users表里面查看加密规则
mysql> use mysql;
Database changed
mysql> select host,user,plugin from user;
+-----------+------------------+-----------------------+
| host | user | plugin |
+-----------+------------------+-----------------------+
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session | caching_sha2_password |
| localhost | mysql.sys | caching_sha2_password |
| localhost | root | caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)
  • host:允许用户登录的 ip,此处如果为 % 表示可以远程;
  • user: 当前数据库的用户名;
  • plugin: 密码加密方式;
  • 在mysql 5.7.9以后废弃了password字段和password()函数
  1. 修改加密规则
	mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.10 sec) mysql> flush privileges;
Query OK, 0 rows affected (0.08 sec)
  1. 修改加密规则后再次查看
mysql> select host,user,plugin from user;
+-----------+------------------+-----------------------+
| host | user | plugin |
+-----------+------------------+-----------------------+
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session | caching_sha2_password |
| localhost | mysql.sys | caching_sha2_password |
| localhost | root | mysql_native_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)
  1. 然后重复一步骤,出现如下错误:

  2. 在步骤2中就发现不能远程,设置如下:

mysql> update user set Host='%' where User='root';
Query OK, 1 row affected (0.12 sec)
Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges;
Query OK, 0 rows affected (0.08 sec)
  1. 再次查看,发现root账号可以远程连接。
mysql> select host,plugin,user from user;
+-----------+-----------------------+------------------+
| host | plugin | user |
+-----------+-----------------------+------------------+
| % | mysql_native_password | root |
| localhost | caching_sha2_password | mysql.infoschema |
| localhost | caching_sha2_password | mysql.session |
| localhost | caching_sha2_password | mysql.sys |
+-----------+-----------------------+------------------+
4 rows in set (0.01 sec)

MySQL的安装、改密及远程连接的更多相关文章

  1. MySql数据库安装&修改密码&开启远程连接图解

    相关工具下载地址: mysql5.6 链接:http://pan.baidu.com/s/1o8ybn4I密码:aim1 SQLyog-12.0.8 链接:http://pan.baidu.com/s ...

  2. MysqL的root用户不允许远程连接

    原文:MysqL的root用户不允许远程连接 今天程序报了异常:java.sql.SQLException: Access denied for user 'root'@'RJB-Z' (using ...

  3. 【MySQL解惑笔记】Navicat 无法远程连接MySQL数据库

    安装好Navicat之后远程连接MySQL数据库出现以下报错截图: 出现以上截图怀疑是mysql用户权限不够: GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.1 ...

  4. 本地不安装oracle,PLsql远程连接

    Oracle的Instant client工具包可以很好地解决本地不安装oracle,PLsql远程连接. 1.首先到Oracle网站下载Instant Client : http://www.ora ...

  5. (亲测成功)在centos7.5上安装kvm,通过VNC远程连接并创建多台ubuntu虚拟机(ubuntu server版本)

    在centos7.5上安装kvm,通过VNC远程连接并创建多台ubuntu虚拟机 前提:服务器端安装桌面版的centos系统 CentOS Linux release 7.5.1804 (Core) ...

  6. linux 下修改mysql下root 权限来允许远程连接

    MySQL默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接. 其操作简单,如下所示: 1. 进入mysql: /usr/local/mysql/bin/ ...

  7. 虚拟机virtualBox安装linux系统 xshell远程连接linux

    虚拟机virtualBox安装linux系统 xshell远程连接linux 虚拟机概念: 通过软件, 使用虚拟化技术虚拟出电脑的硬件环境, 充当真实的电脑使用. 常见的虚拟软件: virtualBo ...

  8. mysql 如果没有密码 就不能远程连接

    mysql 如果没有密码 就不能远程连接

  9. [运维] 如何在云服务器上安装 MySQL 数据库, 并使用 Navicat 实现远程连接管理

    .•●•✿.。.:*.•●•✿.。.:*.•●•✿.。.:*.•●•✿.。.:*.•●•✿.。.:*.•●•✿.。.:*.•.•●•✿.。.:*.•●•✿.。.:*.•●•✿.。.:*.•●•✿.。. ...

随机推荐

  1. 哎,这让人抠脑壳的 LFU。

    这是why哥的第 83 篇原创文章 让人抠脑壳的 LFU 前几天在某APP看到了这样的一个讨论: 看到一个有点意思的评论: LFU 是真的难,脑壳都给我抠疼了. 如果说 LRU 是 Easy 模式的话 ...

  2. 讲讲Java8的Optional类

    前言 Java 8中引入了 Optional 类来解决 NullPointerException 与繁琐的 null 检查,该类首次出现在 Guava.Java 8 才成为类库中的一部分. 入门 Op ...

  3. XSS-labs通关挑战(xss challenge)

    XSS-labs通关挑战(xss challenge) 0x00 xss-labs   最近在看xss,今天也就来做一下xss-labs通过挑战.找了好久的源码,终于被我给找到了,因为在GitHub上 ...

  4. Docker学习笔记之查看Docker

    命令: 使用history命令查看镜像历史 使用cp命令复制容器中的文件到主机 使用commit命令把修改过的容器创建为镜像 使用diff命令检查容器文件的修改 使用inspect命令查看容器/镜像详 ...

  5. 系统吞吐量与QPS/TPS

    QPS/TPS QPS:Queries Per Second意思是"每秒查询率",是一台服务器每秒能够相应的查询次数,是对一个特定的查询服务器在规定时间内所处理流量多少的衡量标准. ...

  6. 前端基础功能,原生js实现轮播图实例教程

    轮播图是前端最基本.最常见的功能,不论web端还是移动端,大平台还是小网站,大多在首页都会放一个轮播图效果.本教程讲解怎么实现一个简单的轮播图效果.学习本教程之前,读者需要具备html和css技能,同 ...

  7. celery应用

    celery---分布式任务队列 Celery是一个简单,灵活且可靠的分布式系统,可以处理大量消息,同时为操作提供维护该系统所需的工具. Celery是一个基于python开发的模块,可以帮助我们对任 ...

  8. 把Win10变成Mac OS:比任何美化主题都好用的工具

    摘要:把Win10变成Mac OS:比任何美化主题都好用的工具 - 这是一款真正意义上的把Windows变成MacOS的软件,不用更换主题,不用修改Dll,直接是程序接管了Explorer,比任何美化 ...

  9. 数据库内核——基于HLC的分布式事务实现深度剖析

    DTCC 2019 | 深度解码阿里数据库实现 数据库内核--基于HLC的分布式事务实现深度剖析-阿里云开发者社区 https://developer.aliyun.com/article/70355 ...

  10. net.core.somaxconn net.ipv4.tcp_max_syn_backlog

    Linux参数-net.core.somaxconn与net.ipv4.tcp_max_syn_backlog_梁海江的博客-CSDN博客_net.ipv4.tcp_max_syn_backlog h ...