一、windows mysql 安装
1、安装到 C:\mysql-8.0.31-winx64
2、根目录下添加配置文件 my.ini
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
[mysqld]
port=3306
default-time-zone='+08:00'
basedir=C:\mysql-8.0.31-winx64
datadir=C:\mysql-8.0.31-winx64\data
max_connections=200
character-set-server=utf8mb4
default-storage-engine=INNODB
[mysqld_safe]
log-error=C:\mysql-8.0.31-winx64\log\mysqld.log
3、将bin目录添加环境变量
4、【管理员身份起动DOS】并完成初始化
mysqld --initialize --console
-----------------------------------------------------------------------
C:\Users\Zhang>mysqld --initialize --console
2023-05-11T01:22:50.046027Z 0 [System] [MY-013169] [Server] C:\mysql-8.0.31-winx64\bin\mysqld.exe (mysqld 8.0.31) initializing of server in progress as process 21536
2023-05-11T01:22:50.070377Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-05-11T01:22:53.727524Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-05-11T01:22:55.519008Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 78*ehoRf9ABc
------------------------------------------------------------------------
5、安装成服务
mysqld --install
6、启动服务
net/sc start mysql
7.查看服务状态
sc queryex mysql
-------------------------------------------------------------------------
C:\Windows\system32>sc queryex mysql
SERVICE_NAME: mysql
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 【RUNNING】
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
PID : 24152
FLAGS :
-------------------------------------------------------------------------
二,Linux mysql安装
1、下载 mysql80-community-release-el7-8.noarch.rpm
文件:
https://dev.mysql.com/downloads/repo/yum/
2、安装RPM包
sudo rpm -Uvh /path/to/mysql80-community-release-el7-8.noarch.rpm
3、检查MySQL存储库是否已添加
yum repolist enabled
4、安装MySQL服务器
yum install mysql-community-server -y
5、检查服务器状态
systemctl status mysqld
6、启动服务器
sudo systemctl start mysqld
7、查找初始密码临时文件
sudo grep 'temporary password' /var/log/mysqld.log
8、登录
mysql -u root -p
9、设置密码安全策略
set global validate_password.policy=0
10、修改密码
alter user 'root'@'localhost' IDENTIFIED BY 'new_password';
三,创建远程连接账号
1、防火墙
systemctl status| stop | disabled firewalld;
2、查看虚拟机mysql占用端口号
show global variables like 'port';
3、创建用户
create user root@'%' identified by 'password'password expire never;
4、为用户授权
grant all on *.* to root@'%';
5、刷新
flush privileges;
6、主机连接虚拟机mysql
mysql -h 192.168.159.130 -u root -p;
7、修改密码
ALTER USER 'root'@'%' IDENTIFIED BY 'new_password';
标签:8.0,31,MySQL,mysqld,下载安装,mysql,password,root,远程
From: https://blog.csdn.net/qq_73347678/article/details/136789175