参考: https://wiki.archlinux.org/index.php/MySQL

1. 安装

使用pacman常规安装

2. btrfs 禁用CoW

mariadb的数据文件如果存储在btrfs上的话, 则需要一步特殊的设置

http://www.cnblogs.com/hugetong/p/8459518.html

3. 安装数据库

┬─[tong@T7:~/Data/anthropoid]─[:: PM]
╰─>$ sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql/

4.  启动数据库

┬─[tong@T7:~/Data/anthropoid]─[:: PM]
╰─>$ sudo systemctl start mariadb.service
┬─[tong@T7:~/Data/anthropoid]─[:: PM]
╰─>$ sudo systemctl status mariadb.service
● mariadb.service - MariaDB 10.1. database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running) since Thu -- :: CST; 6s ago
Docs: man:mysqld()
https://mariadb.com/kb/en/library/systemd/
Process: ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=/SUCCESS)
Process: ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq ] && systemctl set-environment _WSREP_START_POSITION=$VA
Process: ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=/SUCCESS)
Main PID: (mysqld)
Status: "Taking your SQL requests now..."
Tasks: (limit: )
CGroup: /system.slice/mariadb.service
└─ /usr/bin/mysqld Feb :: T7 mysqld[]: -- :: [Note] InnoDB: Highest supported file format is Barracuda.
Feb :: T7 mysqld[]: -- :: [Note] InnoDB: rollback segment(s) are active.
Feb :: T7 mysqld[]: -- :: [Note] InnoDB: Waiting for purge to start
Feb :: T7 mysqld[]: -- :: [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.6.36-83.0 started; log sequence number 1616717
Feb :: T7 mysqld[]: -- :: [Note] Plugin 'FEEDBACK' is disabled.
Feb :: T7 mysqld[]: -- :: [Note] InnoDB: Dumping buffer pool(s) not yet started
Feb :: T7 mysqld[]: -- :: [Note] Server socket created on IP: '::'.
Feb :: T7 mysqld[]: -- :: [Note] /usr/bin/mysqld: ready for connections.
Feb :: T7 mysqld[]: Version: '10.1.31-MariaDB' socket: '/run/mysqld/mysqld.sock' port: MariaDB Server
Feb :: T7 systemd[]: Started MariaDB 10.1. database server.

5. 设置密码之类的

┬─[tong@T7:~/Data/anthropoid]─[:: PM]
╰─>$ mysql_secure_installation 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
you haven't set the root password yet, the password will be blank,
so you should just press enter here. Enter current password for root (enter for none):
OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation. Set root password? [Y/n] Y
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. Remove anonymous users? [Y/n] Y
... Success! Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y
... 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. Remove test database and access to it? [Y/n] Y
- 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. 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!

6. 可以用了

┬─[tong@T7:~/Data/anthropoid]─[:: PM]
╰─>$ mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 10.1.-MariaDB MariaDB Server Copyright (c) , , Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>

7. 禁止远程访问数据库

因为我就是为了使用gnucash, 本地使用就够了.

┬─[tong@T7:~/Data/anthropoid]─[:: PM]
╰─>$ sudo sed -i "s/#skip-networking/skip-networking/g" /etc/mysql/my.cnf

改完配置,重启服务, 发现监听端口已经不在了.

─[tong@T7:~/Data/anthropoid]─[:: PM]
╰─>$ sudo netstat -nap |grep mysqld
tcp6 ::: :::* LISTEN /mysqld
unix [ ACC ] STREAM LISTENING /mysqld /run/mysqld/mysqld.sock
unix [ ] STREAM CONNECTED /mysqld
┬─[tong@T7:~/Data/anthropoid]─[:: PM]
╰─>$ sudo systemctl restart mariadb.service
┬─[tong@T7:~/Data/anthropoid]─[:: PM]
╰─>$ sudo netstat -nap |grep mysqld
unix [ ACC ] STREAM LISTENING /mysqld /run/mysqld/mysqld.sock
unix [ ] STREAM CONNECTED /mysqld

8. 设置自启动

┬─[tong@T7:~/Data/anthropoid]─[:: PM]
╰─>$ sudo systemctl enable mariadb.service
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.

9. 创建数据库

见文档:https://mariadb.com/kb/en/library/create-database/

其中,需要注意的是字符集问题, 见: https://mariadb.com/kb/en/library/setting-character-sets-and-collations/

character-sets很好理解, 但是collations是什么? 用来排序比较大小? 好吧....

https://mariadb.com/kb/en/library/character-set-and-collation-overview/

A character set is a set of characters while a collation is the rules for comparing and sorting a particular character set.

然而, 在arch上,我的默认就是UTF8MB4, 所以直接create database就行了.

MariaDB [mysql]> show variables like "character_set_server";
+----------------------+---------+
| Variable_name | Value |
+----------------------+---------+
| character_set_server | utf8mb4 |
+----------------------+---------+
row in set (0.00 sec) MariaDB [mysql]> show variables like "collation_server";
+------------------+--------------------+
| Variable_name | Value |
+------------------+--------------------+
| collation_server | utf8mb4_unicode_ci |
+------------------+--------------------+
row in set (0.00 sec)

另外, 有关utf8MB4

嗯, 然后创建gnucash的数据库.

MariaDB [mysql]> create database gnucash;
Query OK, row affected (0.01 sec) MariaDB [mysql]> show create database gnucash;
+----------+------------------------------------------------------------------------------------------------+
| Database | Create Database |
+----------+------------------------------------------------------------------------------------------------+
| gnucash | CREATE DATABASE `gnucash` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */ |
+----------+------------------------------------------------------------------------------------------------+
row in set (0.00 sec)

10 创建gnucash用户

文档: https://mariadb.com/kb/en/library/create-user/

创建用户比创建数据库要稍微复杂一些.

a. account name

Account names have both a user name and a host name, and are specified as 'user_name'@'host_name'.

When you connect to a MariaDB server, your user name and host must match a single account.

The user name and host name may be unquoted, quoted as strings using double quotes (") or single quotes ('), or quoted as identifiers using backticks (`). 
You must use quotes when using special characters (such as a hyphen) or wildcard characters. If you quote, you must quote the user name and host
name separately (for example 'user_name'@'host_name').
If the host name is not provided, it is assumed to be '%'.
User names must match exactly, including case. You can use the empty string to allow a user with any user name.

建!

MariaDB [mysql]> create user 'gnucash'@'localhost' identified by 'xxxxyyy'
-> ;
Query OK, rows affected (0.00 sec)

b. grant

https://mariadb.com/kb/en/library/grant/

MariaDB [mysql]> grant all privileges on gnucash.* to 'gnucash'@'localhost'
-> ;
Query OK, rows affected (0.00 sec)
MariaDB [mysql]> flush privileges;
Query OK, rows affected (0.00 sec)

11 GUI client

找了好多, 除了phpmyadmin, 只有dbeaver可以用... 而且免费.... 但是phpmyadmin需要配http server, 所以还是用dbeaver.

但是dbeaver不能链接本地socket, 必须通过网络,开监听.

$ yaourt -S dbeaver

[daily][mariadb][mysql] mariadb快速设置的更多相关文章

  1. mariadb/mysql使用Navicat连接报错

    [问题1] 使用Navicat连接服务器的mariadb/mysql时报错 access denied for user root@192.168.xx.xx(using password:yes) ...

  2. Ubuntu安装MySQL/MariaDB

    安装MariaDB/MySQL MariaDB是MySQL的分支,与MySQL高度兼容,几乎所有的命令都一样.MariaDB是由前MySQL的开发人员离开Sun公司后开发的,目的是为了防止Oracle ...

  3. MySQL/MariaDB数据库的主从级联复制

      MySQL/MariaDB数据库的主从级联复制 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.主从复制类型概述 1>.主从复制 博主推荐阅读: https://ww ...

  4. Mariadb/MySQL数据库单表查询基本操作及DML语句

    Mariadb/MySQL数据库单表查询基本操作及DML语句 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一数据库及表相关概述 1>.数据库操作 创建数据库: CREATE ...

  5. 在CentOS 7 MySQL / MariaDB

    在CentOS7中,MariaDB  替代了MySQL;更多复杂的疑问可以在这里查看 MariaDB versus MySQL – Compatibility Install MySQL / Mari ...

  6. MySQL/MariaDB数据库的mysqldump工具备份还原实战

    MySQL/MariaDB数据库的mysqldump工具备份还原实战 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.mysqldump概述 1>.逻辑备份工具 mysq ...

  7. MySQL/MariaDB数据库的函数

      MySQL/MariaDB数据库的函数 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. MySQL/MariaDB数据库的函数分为系统函数和用户自定义函数(user-define ...

  8. mariadb(MySql)设置远程访问权限

    [问题]mariadb(MySql)安装之后,本地连接mysql是可以的,但是远程的机器不能连接和访问. [解决]修改mysql远程连接的ip限制配置. [步骤]1.本地mysql客户端连接mysql ...

  9. (MariaDB/MySQL)之DML(1):数据插入

    本文目录: 1.insert和replace插入数据 1.1 insert into values() 1.2 insert into set 1.3 insert into select_state ...

随机推荐

  1. react学习笔记1之声明组件的两种方式

    //定义组件有两种方式,函数和类 function Welcome(props) { return <h1>Hello, {props.name}</h1>; } class ...

  2. Selenium Web 自动化 - 项目实战(二)

    Selenium Web 自动化 - 项目实战(二) 2016-08-08 什么是数据驱动?简答的理解就是测试数据决定了测试结果,这就是所谓数据驱动.数据驱动包含了数据,他就是测试数据,在自动化领域里 ...

  3. 【iCore1S 双核心板_FPGA】例程十五:基于I2C的ARM与FPGA通信实验

    实验现象: 核心代码: int main(void) { int i,n; ]; ]; HAL_Init(); system_clock.initialize(); led.initialize(); ...

  4. JS原生实现视频弹幕Demo(仿)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...

  5. Android 测试入门之---Monkey test

    这周重点学习的也是Android monkey test 的一些相关知识,也对其进行了初步的操作和试验.讲学习资料整理如下 : Monkey是一个命令行工具 ,可以运行在模拟器里或实际设备中.它向系统 ...

  6. 常用curl测试命令

    1.curl 基础用法 2.curl 常用 3.curl 拓展 1.curl基础用法 语法:# curl [option] [url] curl除了用以请求数据,还可以用来上传下载 -A/--user ...

  7. 【转】Windows下charles 使用教程指南

    1.下载就不用再说了,网上好多破解的安装包 2.下面是pc端的抓包使用情况 Charles支持抓去http.https协议的请求,不支持socket.然后charles会自动配置IE浏览器和工具的代理 ...

  8. elasticsearch client 为空 错误信息:java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecut‌​or()Ljava/util/concu‌​rrent/Executor

    错误信息:java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecut‌​or() ...

  9. Office 2007 打开时总是出现配置进度框

    解决办法: cmd 打开控制台 输入命令:reg add HKCU\Software\Microsoft\Office\12.0\Word\Options /v NoReReg /t REG_DWOR ...

  10. JConsole & JVisualVM远程监视Websphere服务器JVM的配置方法

    原文链接:http://xjsunjie.blog.51cto.com/999372/1331880/ jconsole是JDK里自带的一个工具,可以监测Java程序运行时所有对象的申请.释放等动作, ...