From 7bf0a7e9586a9d7c3ba0cffd1aec020dbba1f816 Mon Sep 17 00:00:00 2001 From: "chen.yang" Date: Fri, 6 Aug 2021 17:07:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20MariaDB=20=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E4=B8=AD=E7=9A=84=E4=B8=80=E4=BA=9B=E9=97=AE=E9=A2=98?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chen.yang --- .../Applications/Docker/Docker_安装和使用.md | 2 +- .../MariaDB/MariaDB_安装配置与使用.md | 39 +++++++++++-------- .../Samba/Linux_搭建_Samba_服务器.md | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Software/Applications/Docker/Docker_安装和使用.md b/Software/Applications/Docker/Docker_安装和使用.md index be44639..1716ec4 100644 --- a/Software/Applications/Docker/Docker_安装和使用.md +++ b/Software/Applications/Docker/Docker_安装和使用.md @@ -16,7 +16,7 @@ published: true ```bash # Ubuntu apt install docker.io -# Arch Linux/Manjaro +# Manjaro pacman -S docker ``` diff --git a/Software/Applications/MariaDB/MariaDB_安装配置与使用.md b/Software/Applications/MariaDB/MariaDB_安装配置与使用.md index 707e37f..372eff3 100644 --- a/Software/Applications/MariaDB/MariaDB_安装配置与使用.md +++ b/Software/Applications/MariaDB/MariaDB_安装配置与使用.md @@ -7,10 +7,10 @@ MariaDB 是与 MySQL 兼容的开源实现,当 Linux 服务器上需要使用 MariaDB 的安装命令如下: ```bash -## Arch Linux -pacman -S mariadb mariadb-clients mariadb-libs -## Ubuntu -apt install mariadb-server mariadb-client libmariadb-dev libmariadbclient-dev +# Manjaro +sudo pacman -S mariadb mariadb-clients mariadb-libs +# Ubuntu +sudo apt install mariadb-server mariadb-client libmariadb-dev libmariadbclient-dev ``` ## 2.初始配置 @@ -18,13 +18,16 @@ apt install mariadb-server mariadb-client libmariadb-dev libmariadbclient-dev 安装完 MariaDB 后需要进行初始配置,首先需要执行以下命令: ```bash -mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql +# Manjaro +sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql +# Ubuntu ? +sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql ``` 之后启动 MariaDB 的系统服务: ```bash -systemctl start mariadb +sudo systemctl start mariadb ``` 最后初始化数据库: @@ -53,9 +56,9 @@ mariadb -u root -p mariadb -h localhost -u root -p # 更改密码(解决普通用户登陆报错:Access denied for user 'root'@'localhost'),请将'passwd'替换为实际的密码 -update user set authentication_string=PASSWORD('passwd') where user='root'; +UPDATE mysql.user set authentication_string=PASSWORD('passwd') where user='root'; # 如果没这一行可能也会报一个错误,因此需要运行这一行 -update user set plugin="mysql_native_password"; +UPDATE mysql.user set plugin="mysql_native_password"; # 强制写入,操作完退出前先进行以下该操作 FLUSH privileges; @@ -76,13 +79,13 @@ SHOW global variables like 'port'; ```bash # 显示所有数据库 -SHOW databases; +SHOW DATABASES; # 删除数据库 -drop database 'database name'; +DROP DATABASE 'database name'; # 选择操作的数据库 -use mysql; +USE mysql; # 创建数据库 CREATE DATABASE 'database name'; @@ -122,7 +125,7 @@ CREATE USER 'm23100'@'%'; # 如果要授予该用户对所有数据库和表的相应操作权限则可用 * 表示, 如 *.* GRANT privileges ON databasename.tablename TO 'username'@'host' # 示例 -GRANT ALL ON test.* to username @ 'localhost' IDENTIFIED BY 'password'; +GRANT ALL ON test.* TO username @ 'localhost' IDENTIFIED BY 'password'; # 撤销用户权限 REVOKE privilege ON databasename.tablename FROM 'username'@'host'; @@ -136,25 +139,27 @@ sudo systemctl stop mariadb # 进入安全模式,并设置为后台进程 sudo mysqld_safe --skip-grant-tables & # 登陆mysql -$ mysql -u root +mariadb -u root ``` ```bash # 查询用户 SELECT Host,User,plugin from mysql.user where User='root'; # 重置加密模式 -update mysql.user set plugin='mysql_native_password'; +UPDATE mysql.user set plugin='mysql_native_password'; # 重置密码 -update mysql.user set password=PASSWORD("newpassword") where User='root'; +UPDATE mysql.user set password=PASSWORD("newpassword") where User='root'; # 刷新权限信息 -flush privileges; +FLUSH privileges; exit ``` ```bash # 杀掉进程 -kill -9 $(pgrep mysql) +sudo kill -9 $(pgrep mysql) # 重新启动服务 +sudo systemctl start mariadb +# 或 service mariadb start # 登陆 mysql mariadb -u root -p diff --git a/Software/Applications/Samba/Linux_搭建_Samba_服务器.md b/Software/Applications/Samba/Linux_搭建_Samba_服务器.md index ceb3c22..52c5aca 100644 --- a/Software/Applications/Samba/Linux_搭建_Samba_服务器.md +++ b/Software/Applications/Samba/Linux_搭建_Samba_服务器.md @@ -92,7 +92,7 @@ pdbedit -L 通过 systemctl 开启 samba 服务命令如下: ```bash -# Arch Linux +# Manjaro systemctl enable smb.service systemctl start smb.service # Ubuntu