MySQL安装配置之云服务器
...小于 1 分钟
MySQL安装配置之云服务器
宝塔中安装MySQL
(1)宝塔面板的系统防火墙放行3306端口
(2)云服务器的防火墙放行3306端口
(3)软件商店搜索并安装MySQL
(4)修改数据库密码
(5)使用命令行工具连接服务器,使用命令mysql -uroot -p 连接数据库
(6)使用命令新建一个用户
# 创建一个用户
create user '用户名'@'%' identified with mysql_native_password by '密码';
# 例如:
create user 'dogusers'@'%' identified with mysql_native_password by '111111111';
# 或者使用下面这条创建用户
create user '用户名'@'%' identified by '密码' with grant option;
(7)赋予权限
# MySQL 5 版本
grant all on *.* to 用户名@'%' identified by '密码' with grant option;
# 例如:
grant all on *.* to dogusers@'%' identified by '111111111' with grant option;
# MySQL 8 版本
alter user '用户名'@'localhost' identified with mysql_native_password by '密码'
(8)切换数据库
use mysql;
(9)允许远程登录
update user set host = '%' where user = '用户名';
#例如
update user set host = '%' where user = 'dogusers';
(10)刷新,使得以上设置生效
flush privileges;
Powered by Waline v3.1.3