manjaro 安装 mariadb

# 安装
sudo pacman -S mariadb
# 初始化
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
# 这段输出很重要!认真读
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is mysql@localhost, it has no password either, but
you need to be the system 'mysql' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at https://mariadb.com/kb

You can start the MariaDB daemon with:
cd '/usr' ; /usr/bin/mysqld_safe --datadir='/var/lib/mysql'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/mysql-test' ; perl mysql-test-run.pl

Please report any problems at https://mariadb.org/jira

The latest information about MariaDB is available at https://mariadb.org/.

Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

抓住几个重要信息:
1、mariadb系统表位置在 /var/lib/mysql

2、将mysqld.server服务复制到启动位置。我们这里已经默认有systemctl start mysqld就可以了,不需要进行复制

3、已经创建了两个所有权限的用户 一个是root用户,另一个是user用户。这俩用户默认都是没有密码的。连接之后可以修改密码。没说明怎样修改密码,另外开个窗口连接看看

# 启动服务
sudo systemctl start mariadb
 
# 查看服务状态
sudo systemctl start mariadb
● mariadb.service - MariaDB 10.7.3 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
     Active: active (running) since Sun 2022-04-17 11:55:09 CST; 9s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/

# 登录
mysql -uroot -p  
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

这里说我没有权限,英文里有这么一句but you need to be system 'root' user to connect,原来我翻译不到位,需要作为系统权限用户才可以。

# 重新登录 sudo 的密码需要输入,第二个Enter password: 直接Enter

sudo mysql -uroot -p

[sudo] my 的密码:
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.7.3-MariaDB Arch Linux

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)]> 

另外一个user用户也是同理也尝试可以进入。

sudo mysql -uuser -p

到了这一步说明数据库是可用的了,但是直接用图示化工具链接还是报ERROR 1698 (28000): Access denied for user 'root'@'localhost'
在这里插入图片描述安全全配置。看输出进行设置

sudo mysql_secure_installation
# 输入sudo的密码
[sudo] my 的密码:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
# 输入当前root的密码、刚安装是空、直接Enter
Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.
# 是否启用 unix_socket 的自动认证。选n
Switch to unix_socket authentication [Y/n] n
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.
# 是否修改root密码,选y
Change the root password? [Y/n] n
# 输入俩次root的新密码
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
# 是否移除仅仅用于测试的匿名用户 n 
Remove anonymous users? [Y/n] n

 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
# 是否禁用root远程登录。本地环境不禁用  选n 。
Disallow root login remotely? [Y/n] n
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
# 是否移除test测试库 本地环境 n 方便图示化工具连接
Remove test database and access to it? [Y/n] n
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
# 是否马上重新加载权限表 选y
Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
# 到这里已经设置完成。可以直接用工具连接了

建议图示化工具用dbeaver https://dbeaver.io/download/

在这里插入图片描述点击测试连接。发现是可以连接成功了的。尽情享受它吧。后面的步骤不用管了。
常用命令:

systemctl start|enable|disable|status mariadb

在这里插入图片描述

以下的我也看不懂了。跳过
4、mariadb守护进程位置

/usr/bin/mysqld_safe --datadir='/var/lib/mysql

5、如何测试守护进程
cd ‘/usr/mysql-test’ ; perl mysql-test-run.pl
mysql-test-run.pl 这个东西在哪没有找到 不管了

6、如果有问题反馈到https://mariadb.org/jira

7、关于mariadb的最新消息在https://mariadb.org/

8、社区https://mariadb.org/get-involved/

我丢。蹩脚英语

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值