Author: Xu FC
MySQL: mysql Ver 15.1 Distrib 10.3.20-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
MySQL 配置
- 修改监听地址和端口, 配置文件
/etc/mysql/mariadb.conf.d/50-server.cnf
port = 3306
bind-address = 0.0.0.0
- 配置修改后,重启 mysql.service 配置即可生效
root@kali:~# netstat -ln | more
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
- 修改密码
mysqladmin -u root -p current_password password new_password
- 连接 MySQL
root@kali:~# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 44
Server version: 10.3.20-MariaDB-1 Debian buildd-unstable
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.001 sec)
- 查看 user
MariaDB [(none)]> 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
MariaDB [mysql]> select user,host from user;
+------+-----------+
| user | host |
+------+-----------+
| root | localhost |
+------+-----------+
1 row in set (0.000 sec)
- 添加一个可以远程连接数据库的用户
MariaDB [mysql]> insert into user
-> (host,user,password,ssl_cipher,x509_issuer,x509_subject,authentication_string)
-> values
-> ('%','xufc',PASSWORD('coco'),'','','',PASSWORD('coco'));
Query OK, 1 row affected (0.000 sec)
MariaDB [mysql]> select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | xufc |
| localhost | root |
+-----------+------+
2 rows in set (0.000 sec)
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.001 sec)
MariaDB [mysql]> quit
Bye
- 通过 VS Code 远程连接 MySQL 远程连接 MySQL
-
添加 database,并授予用户到该数据库的权限
MariaDB [(none)]> create database BugStatis;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> GRANT ALL privileges ON BugStatis.* TO 'xufc'@'%';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| BugStatis |
| information_schema |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.001 sec)
- 通过 VS Code 连接数据库 连接数据库
网友评论