在尝试运行mariadb之前,首先确定其当前状态,运行或关闭。 有三个选项用于启动和停止mariadb -
如果您将mariadb安装在非标准位置,则可能需要在脚本文件中编辑位置信息。 只需在脚本中添加“停止”参数,即可停止mariadb。
如果您想在linux下自动启动它,请将启动脚本添加到init系统中。 每个分发具有不同的过程。 请参阅系统文档。
使用以下代码创建新的用户帐户 -
'newusername'@'localhost' identified by 'userpassword';
此代码向用户表中添加一行没有任何权限。 您还可以选择使用哈希值作为密码。 使用以下代码授予用户权限 -
grant select, insert, update, delete on database1 to 'newusername'@'localhost';
其他权限包括mariadb中可能的每个命令或操作。 创建用户后,执行“flush privileges”命令以刷新授权表。 这允许使用用户帐户。
在unix / linux上构建之后,应该编辑配置文件“/etc/my.conf”以显示如下 -
# example mysql config file. # you can copy this to one of: # /etc/my.cnf to set global options, # /mysql-data-dir/my.cnf to get server specific options or # ~/my.cnf for user specific options. # # one can use all long options that the program supports. # run the program with --help to get a list of available options # this will be passed to all mysql clients [client] #password = my_password #port = 3306 #socket = /tmp/mysql.sock # here is entries for some specific programs # the following values assume you have at least 32m ram # the mysql server [mysqld] #port = 3306 #socket = /tmp/mysql.sock temp-pool # the following three entries caused mysqld 10.0.1-mariadb (and possibly other versions) to abort... # skip-locking # set-variable = key_buffer = 16m # set-variable = thread_cache = 4 loose-innodb_data_file_path = ibdata1:1000m loose-mutex-deadlock-detector gdb ######### fix the two following paths # where you want to have your database data = /path/to/data/dir # where you have your mysql/mariadb source + sql/share/english language = /path/to/src/dir/sql/share/english [mysqldump] quick mariadb 8 set-variable = max_allowed_packet=16m [mysql] no-auto-rehash [myisamchk] set-variable = key_buffer = 128m
编辑行"data ="和"language ="以匹配您的环境。
文件修改后,导航到源目录并执行以下操作 -
./scripts/mysql_install_db --srcdir = $pwd --datadir = /path/to/data/dir -- 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子句用于获取表名后显示的模式。