mysql数据库安装
安装环境:centos7
配置源:
# wget https://dev.mysql.com/get/mysql84-community-release-el7-1.noarch.rpm
# yum install mysql84-community-release-el7-1.noarch.rpm
安装mysql
# yum install mysql-community-server
启动
# systemctl enable --now mysqld
查看版本
# mysql -V
mysql Ver 8.4.5 for Linux on x86_64 (MySQL Community Server - GPL)
记录密码:
# grep 'temporary password' /var/log/mysqld.log
2025-06-20T02:39:05.207307Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: m6H+&&YX4j*R
登录mysql
[root@tongweb ~]# mysql -uroot -p'上一步查看到的密码'
修改root@localhost,否则无法进行其他操作
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Passw0rd!Q@W#E';
flush privileges;
创建远程连接账号
CREATE USER 'songwei'@'%' IDENTIFIED BY 'A6789@jkl';
GRANT ALL PRIVILEGES ON *.* TO 'songwei'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;