mysql
mysql安装
创建用户
CREATE USER 'demo'@'%' IDENTIFIED BY '123456';
授予用户访问权限
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| demo | % |
| root | % |
| debian-sys-maint | localhost |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
+------------------+-----------+
6 rows in set (0.00 sec)
# 授予用户访问某个数据库的权限
GRANT ALL PRIVILEGES ON database_name.* TO 'user_name'@'允许访问ip地址';
允许远程
# 允许远程 SSH 使用密码登录
sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sudo systemctl restart sshd
允许来自任意ip地址的连接(mysql级别)
# /etc/mysql/my.cnf文件增加以下内容
[mysqld]
port=3306
bind-address=0.0.0.0
mysqlx-bind-address = 0.0.0.0
评论区