安装免安装版mysql
2020-09-16 本文已影响0人
Rinaloving
访问mysql官网下载想要版本的数据库
downloadMySql.png解压mysql到相应目录中
QQ截图20200916230140.png配置系统环境(只要搞过java环境的基本上不陌生,这里不详述)
QQ截图20200916230555.png补充:2022.05.07
系统属性.png
编辑环境变量.png
C:\Program Files\MySQL\MySQL Server 8.0\bin
mysql解压的目录新建一个my.ini文件
QQ截图20200916230811.png QQ图片20200916230940.jpg把几个盘符改成自己mysql解压所在的盘符目录
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3306
# 设置mysql的安装目录
basedir="D:\mysql5.7.21"
# 设置mysql数据库的数据的存放目录
datadir="D:\mysql5.7.21\data"
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 区分大小写
lower_case_table_names=2
[WinMySQLAdmin]
Server=D:\mysql5.7.21\bin\mysqld.exe
打开 Windows PowerShell
QQ截图20200916231133.png按照如下命令操作
QQ图片20200916225552.jpgWindows PowerShell
版权所有 (C) 2013 Microsoft Corporation。保留所有权利。
PS C:\Users\Administrator> cd D:\mysql5.7.21\bin
PS D:\mysql5.7.21\bin> mysqld install
The service already exists!
The current server installed: D:\mysql5.7.21\bin\mysqld MySQL
PS D:\mysql5.7.21\bin> mysqld --remove mysql
Service successfully removed.
PS D:\mysql5.7.21\bin> mysqld install
Service successfully installed.
PS D:\mysql5.7.21\bin> mysqld --initialize-insecure --user==mysql
PS D:\mysql5.7.21\bin> net strat mysql
此命令的语法是:
NET
[ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
HELPMSG | LOCALGROUP | PAUSE | SESSION | SHARE | START |
STATISTICS | STOP | TIME | USE | USER | VIEW ]
PS D:\mysql5.7.21\bin> net strat mysql
此命令的语法是:
NET
[ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
HELPMSG | LOCALGROUP | PAUSE | SESSION | SHARE | START |
STATISTICS | STOP | TIME | USE | USER | VIEW ]
PS D:\mysql5.7.21\bin> net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
PS D:\mysql5.7.21\bin> mysql
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)
PS D:\mysql5.7.21\bin> mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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> set password=password('root')
-> ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
PS D:\mysql5.7.21\bin> 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.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, 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>
--注释
8.0.1版本
8.0.1.png
如果想用ip连接数据库需要设置一下
设置授权.pngGRANT ALL PRIVILEGES ON *.* TO root@"192.168.1.11" IDENTIFIED BY "root" WITH GRANT OPTION;
flush privileges;
最后用sqlyog可以直接连接上
QQ截图20200916231612.png主要总结这几天的工作,部分图片为后截取(不一定是配套,但是过程没有缺少)。
补充
服务器上配置好后远程无法连接,报异常(解决方法如下)
QQ图片20200917195041.png解决方法(可无视报错)
QQ图片20200917195059.pngPS C:\Users\Administrator> mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 41
Server version: 5.7.31 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> update user set host = '%' where user = 'root';
ERROR 1046 (3D000): No database selected
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> use mysql
Database changed
mysql> update user set host = '%' where user = 'root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>
成功连接
QQ图片20200917195048.png连接错误
报错:plugin caching_sha2_password could not be loaded
错误号码2058.png
解决方法:
#修改加密规则
ALTER USER 'root'@'localhost' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER;
#更新一下用户的密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
#刷新权限
FLUSH PRIVILEGES;
问题解决记录.png
Microsoft Windows [版本 10.0.14393]
(c) 2016 Microsoft Corporation。保留所有权利。
C:\Users\Administrator>mysql
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)
C:\Users\Administrator>mysql -uroot -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.15 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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql>
再次连接正常
连接成功.png