课程表

MariaDB课程

工具箱
速查手册

MariaDB 管理

当前位置:免费教程 » 数据库/运维 » MariaDB

在尝试运行MariaDB之前,首先确定其当前状态,运行或关闭。 有三个选项用于启动和停止MariaDB - 

  • 运行mysqld(MariaDB脚本)。
  • 运行mysqld_safe启动脚本。
  • 运行mysql.server启动脚本。

如果您将MariaDB安装在非标准位置,则可能需要在脚本文件中编辑位置信息。 只需在脚本中添加“停止”参数,即可停止MariaDB。

如果您想在Linux下自动启动它,请将启动脚本添加到init系统中。 每个分发具有不同的过程。 请参阅系统文档。

创建用户帐户

使用以下代码创建新的用户帐户 -

  1. 'newusername'@'localhost' IDENTIFIED BY 'userpassword';

此代码向用户表中添加一行没有任何权限。 您还可以选择使用哈希值作为密码。 使用以下代码授予用户权限 -

  1. GRANT SELECT, INSERT, UPDATE, DELETE ON database1 TO 'newusername'@'localhost';

其他权限包括MariaDB中可能的每个命令或操作。 创建用户后,执行“FLUSH PRIVILEGES”命令以刷新授权表。 这允许使用用户帐户。

配置文件

在Unix / Linux上构建之后,应该编辑配置文件“/etc/my.conf”以显示如下 -

  1. # Example mysql config file.
  2. # You can copy this to one of:
  3. # /etc/my.cnf to set global options,
  4. # /mysql-data-dir/my.cnf to get server specific options or
  5. # ~/my.cnf for user specific options.
  6.  
  7. #
  8.  
  9. # One can use all long options that the program supports.
  10. # Run the program with --help to get a list of available options
  11.  
  12. # This will be passed to all mysql clients
  13. [client]
  14. #password = my_password
  15. #port = 3306
  16. #socket = /tmp/mysql.sock
  17.  
  18. # Here is entries for some specific programs
  19. # The following values assume you have at least 32M ram
  20.  
  21. # The MySQL server
  22. [mysqld]
  23. #port = 3306
  24. #socket = /tmp/mysql.sock
  25. temp-pool
  26.  
  27. # The following three entries caused mysqld 10.0.1-MariaDB (and possibly other
  28. versions) to abort...
  29. # skip-locking
  30. # set-variable = key_buffer = 16M
  31. # set-variable = thread_cache = 4
  32.  
  33. loose-innodb_data_file_path = ibdata1:1000M
  34. loose-mutex-deadlock-detector
  35. gdb
  36.  
  37. ######### Fix the two following paths
  38.  
  39. # Where you want to have your database
  40. data = /path/to/data/dir
  41.  
  42. # Where you have your mysql/MariaDB source + sql/share/english
  43. language = /path/to/src/dir/sql/share/english
  44.  
  45. [mysqldump]
  46. quick
  47. MariaDB
  48. 8
  49. set-variable = max_allowed_packet=16M
  50. [mysql]
  51. no-auto-rehash
  52.  
  53. [myisamchk]
  54. set-variable = key_buffer = 128M

编辑行"data ="和"language ="以匹配您的环境。

文件修改后,导航到源目录并执行以下操作 -

  1. ./scripts/mysql_install_db --srcdir = $PWD --datadir = /path/to/data/dir --
  2. user = $LOGNAME

如果您将datadir添加到配置文件,请忽略“$ PWD”变量。 确保运行10.0.1版本的MariaDB时使用“$ LOGNAME”。

管理命令

查看以下您将在使用MariaDB时经常使用的重要命令列表:

  • USE [database name] - 设置当前默认数据库。

  • SHOW DATABASES - 列出服务器上当前的数据库。

  • SHOW TABLES - 列出所有非临时表。

  • SHOW COLUMNS FROM [table name] - 提供与指定表有关的列信息。

  • SHOW INDEX FROM TABLENAME [table name] - 提供与指定表相关的表索引信息。

  • SHOW TABLE STATUS LIKE [table name] \ G - - 提供有关非临时表的信息的表,以及LIKE子句用于获取表名后显示的模式。

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号