服务器装置 MySQL
服务器应用 CentOS7
数据库装置
-
查看是否有装置 MySQL
yum list installed | grep mysql
-
下载 MySQL 安装包,这里下载的是 8.0
wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm
-
应用 yum 装置 rpm 包
yum -y install mysql80-community-release-el7-2.noarch.rpm
-
装置 MySQL 服务,过程比较慢,须要下载
yum -y install mysql-community-server
MySQL 配置
-
启动 MySQL 服务,记得是 mysqld
systemctl start mysqld.service
-
查看 MySQL 运行状态
systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since 三 2021-07-28 16:44:56 CST; 1min 26s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 17913 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 18001 (mysqld) Status: "Server is operational" CGroup: /system.slice/mysqld.service └─18001 /usr/sbin/mysqld 7 月 28 16:44:47 VM-12-5-centos systemd[1]: Starting MySQL Server... 7 月 28 16:44:56 VM-12-5-centos systemd[1]: Started MySQL Server.
-
重启 / 进行服务
service mysqld restart #重新启动 Mysql systemctl stop mysqld.service #进行 Mysql
-
查看 MySQL 的 root 用户初始密码
grep "password" /var/log/mysqld.log 2021-07-28T08:44:50.767029Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: r!FYj6ujDhx%
-
登录 root 用户
mysql -u root -p
-
批改 root 明码
# 能够先设置容许简略明码 set global validate_password.policy=0;set global validate_password.length=4;# 批改明码 ALTER USER 'root'@'localhost' IDENTIFIED BY '你的明码';
-
敞开 yum 自动更新
yum -y remove mysql80-community-release-el7-2.noarch
至此 MySQL 曾经装置实现
客户端近程操作数据库
-
查看是否开启了 3306 端口
我的服务器是腾讯云,所以在控制台配置端口就行了,如果不是能够自行百度
-
MySQL 设置容许近程登录
USE mysql;UPDATE USER SET host = '%' WHERE USER = 'root';FLUSH PRIVILEGES;
- 而后应用客户端登录即可
不定期更新:Github