mysql8.x non-registered use [{green use]

mysql8.x non-registered use [{green use]:
Sometimes you need to install multiple different versions of mysql on your computer. I don’t want to always register something. If you want to be the same as the green version, start it directly when you use it, and close the service when you don’t use it. can

1. Download the compressed version from the official website [mysql-8.0.22-winx64]
j. After decompression, store it in the location: D:\db\mysql-8.0.22-winx64
2. Create a new file my.ini file here. The
content is as follows:

[mysqld]
default_authentication_plugin=mysql_native_password
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=D:\db\mysql-8.0.22-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\db\mysql-8.0.22-winx64\data
# 允许最大连接数
max_connections=200
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为UTF8
character-set-server=utf8MB4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
 
default-character-set=utf8mb4

3. Enter cd mysql-8.0.11-winx64\bin and execute the following command [System Administrator Mode], wait a minute or so...

D:\db\mysql-8.0.22-winx64\bin>

mysqld --defaults-file=D:\db\mysql-8.0.22-winx64\my.ini --initialize --console

4. After initialization, register to view the window information, and view the password in two ways
1. View directly on the interface2
. Enter the data directory of mysql and check the file with the *.err suffix, you can see the initial password
Insert picture description here
Insert picture description here
Insert picture description here
5. Close all mysql cmd windows, then re-open mysqld in the bin directory and another cmd login, use mysql -uroot -p to
enter the password you just obtained: the service is started, the green version of MySQL is started

6. At this time, using mysql prompts an error and is not allowed to use

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>

7。需要重新设置一个密码才能操作数据库

7.1 Modify the plane command, modify the password to R1234567890

alter user 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'R1234567890';

8. Enter the create database command to test whether it is feasible
9. A green version of MySQL is deployed. During the subsequent use, you only need to start mysqld in the bin directory, and you can use the mysql tool to directly access the database.

-----------------------The following is optional-----
10. At present, root users can access the database locally, but local users cannot be accessed by LAN or remote users Need to enable remote user access permissions.

10.1 Now change him to remote login

mysql> update user set host='%' where user='root';

10.2
Refresh permissions

FLUSH PRIVILEGES;

10. Through the Navicat access or use the client to test the access data, complete the data access.
At this point, a mysql8.x version database, when using it, directly start mysqld[cmd administrator start], you can start a mysql8 database, no need to close mysqld directly, the next time you use it, it will become A green version of mysql
, this environment is only used for students who are studying or frequently changing versions, not for production environments.

Guess you like

Origin blog.csdn.net/wtt234/article/details/109952187
use
use