MySQL 安装 及 SQLyog配置

发布时间 2023-06-26 08:02:13作者: zjfun

安装步骤 

1. www.sql.com 下载社区版

下载后解压

 2. 新建MySQL配置文件

创建 D:\environ\mysql-8.0.33\my.ini文件

[mysqld]
#set basedir to your installation path
basedir=D:\environ\mysql-8.0.33\
#set datadir to the location of your data directory
datadir=D:\environ\mysql-8.0.33\data\
port=3306
skip-grant-tables
#防止启动失败
shared-memory

3. 启动管理模式下的CMD,运行所有的命令。

d:\environ\mysql-8.0.33\bin> mysqld -install (安装mysql)
d:\environ\mysql-8.0.33\bin> mysqld --initialize-insecure --user=mysql (初始化数据文件)

4. 启动Mysql服务

d:\environ\mysql-8.0.33\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

此时如果发现启动自动停止,请运行 mysqld --console 发现这个错误;在 my.ini当中加入 shared-memory 即可解决。详情参见:XAMPP and MySQL error on startup - Stack Overflow

D:\environ\mysql-8.0.33\bin>mysqld --console
2023-06-25T14:24:14.163059Z 0 [System] [MY-010116] [Server] D:\environ\mysql-8.0.33\bin\mysqld.exe (mysqld 8.0.33) starting as process 24276
2023-06-25T14:24:14.174313Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-06-25T14:24:14.624625Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-06-25T14:24:14.825195Z 0 [Warning] [MY-011311] [Server] Plugin mysqlx reported: 'All I/O interfaces are disabled, X Protocol won't be accessible'
2023-06-25T14:24:14.899629Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-06-25T14:24:14.899810Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-06-25T14:24:14.982672Z 0 [System] [MY-010931] [Server] D:\environ\mysql-8.0.33\bin\mysqld.exe: ready for connections. Version: '8.0.33'  socket: ''  port: 0  MySQL Community Server - GPL.
2023-06-25T14:24:14.983859Z 0 [ERROR] [MY-010131] [Server] TCP/IP, --shared-memory, or --named-pipe should be configured on NT OS
2023-06-25T14:24:14.984068Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-06-25T14:24:16.224947Z 0 [ERROR] [MY-013183] [InnoDB] Assertion failure: trx0sys.cc:643:UT_LIST_GET_LEN(trx_sys->mysql_trx_list) == 0 thread 5636
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
2023-06-25T14:24:16Z UTC - mysqld got exception 0x16 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
7ff61d053298    mysqld.exe!my_print_stacktrace()[stacktrace.cc:429]
7ff61c1cc711    mysqld.exe!print_fatal_signal()[signal_handler.cc:158]
7ff61c1cc453    mysqld.exe!my_server_abort()[signal_handler.cc:269]
7ff61d036c4a    mysqld.exe!my_abort()[my_init.cc:263]
7ff61d204859    mysqld.exe!ut_dbg_assertion_failed()[ut0dbg.cc:99]
7ff61d102f7e    mysqld.exe!trx_sys_close()[trx0sys.cc:643]
7ff61d1c345f    mysqld.exe!srv_shutdown()[srv0start.cc:3078]
7ff61d0a3aca    mysqld.exe!innodb_shutdown()[ha_innodb.cc:1609]
7ff61bfb320b    mysqld.exe!ha_finalize_handlerton()[handler.cc:742]
7ff61bfd0164    mysqld.exe!plugin_deinitialize()[sql_plugin.cc:1121]
7ff61bfd5c78    mysqld.exe!reap_plugins()[sql_plugin.cc:1190]
7ff61bfd48c0    mysqld.exe!plugin_shutdown()[sql_plugin.cc:2090]
7ff61bf6dcd2    mysqld.exe!clean_up()[mysqld.cc:2624]
7ff61bf80e0d    mysqld.exe!unireg_abort()[mysqld.cc:2487]
7ff61bf7f7ac    mysqld.exe!setup_conn_event_handler_threads()[mysqld.cc:3323]
7ff61bf83362    mysqld.exe!win_main()[mysqld.cc:8238]
7ff61bf7ba55    mysqld.exe!mysql_service()[mysqld.cc:8333]
7ff61bf7c05b    mysqld.exe!mysqld_main()[mysqld.cc:8549]
7ff61d87fd44    mysqld.exe!__scrt_common_main_seh()[exe_common.inl:288]
7ffc82af26ad    KERNEL32.DLL!BaseThreadInitThunk()
7ffc846aa9f8    ntdll.dll!RtlUserThreadStart()
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.

 

5. 启动mysql后,在windows command下运行  mysql -u root -p进入下面界面 (密码为空)

D:\environ\mysql-8.0.33\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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>

6. 进入Mysql后修改密码。

修改密码的命令为 

mysql> update mysql.user set authentication_string=password('123456') where user='root' and Host='localhost';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('123456') where user='root' and Host='localhost'' at line 1

如果出现这个错误,说明是MySQL 8.0.xx版本,请换成另外一个命令;并且需要flush一下,详情参见:linux - Turn off --skip-grant-tables in MySQL - Unix & Linux Stack Exchange

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.02 sec)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> exit

成功修改密码

mysql> update mysql.user set authentication_string=password('123456') where user='root' and Host='localhost';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('123456') where user='root' and Host='localhost'' at line 1

mysql -u root -p 

7. 修改my.ini文件,删除 skip-grant-tables

8.重启mysql

D:\environ\mysql-8.0.33\bin>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。


D:\environ\mysql-8.0.33\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

 

 9. 删除MySQL 服务

从windows当中删除mysql services

D:\environ\mysql-8.0.33\bin>sc delete mysql
[SC] DeleteService 成功

或者

mysqld --remove

 

SQLyog配置

1.Download 下载SQLyog软件

配置链接

 可能会出现 2058 plugin caching_sha2_password could not be loaded的错误;原因是: Fixing "Authentication plugin 'caching_sha2_password' cannot be loaded" errors | Chris Shennan

也即是在my.ini 配置,同时在mysql配置,如下:

D:\environ\mysql-8.0.33\bin>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.33 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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 WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)

mysql>

之后,连接成功。