在嘗試運行MariaDB之前,首先確定其當前狀態(tài),運行或關閉。 有三個選項用于啟動和停止MariaDB -
如果您將MariaDB安裝在非標準位置,則可能需要在腳本文件中編輯位置信息。 只需在腳本中添加“停止”參數(shù),即可停止MariaDB。
如果您想在Linux下自動啟動它,請將啟動腳本添加到init系統(tǒng)中。 每個分發(fā)具有不同的過程。 請參閱系統(tǒng)文檔。
使用以下代碼創(chuàng)建新的帳戶。
CREATE USER 'username' @ 'localhost' IDENTIFIED BY 'password';
username字段是你創(chuàng)建的用戶名。localhost表示該用戶只能本地登錄(不能遠程登錄),password字段是這個用戶的密碼。
此代碼可以在用戶表中添加一個沒有任何權限的用戶。
您還可以選擇使用哈希值作為密碼
使用以下代碼授予用戶權限 。
GRANT SELECT, INSERT, UPDATE, DELETE ON database1 TO 'newusername'@'localhost';
其他權限包括MariaDB中可能的每個命令或操作。
授予用戶權限后,執(zhí)行“FLUSH PRIVILEGES”命令刷新授權表,用戶才能獲取權限。
完成以上操作后就可以使用創(chuàng)建的新的用戶了。
在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 ="以匹配您的環(huán)境。
文件修改后,導航到源目錄并執(zhí)行以下操作 -
./scripts/mysql_install_db --srcdir = $PWD --datadir = /path/to/data/dir -- user = $LOGNAME
如果您將datadir添加到配置文件,請忽略“$ PWD”變量。 確保運行10.0.1版本的MariaDB時使用“$ LOGNAME”。
查看以下您將在使用MariaDB時經(jīng)常使用的重要命令列表:
USE [database name] - 設置當前默認數(shù)據(jù)庫。
SHOW DATABASES - 列出服務器上當前的數(shù)據(jù)庫。
SHOW TABLES - 列出所有非臨時表。
SHOW COLUMNS FROM [table name] - 提供與指定表有關的列信息。
SHOW INDEX FROM TABLENAME [table name] - 提供與指定表相關的表索引信息。
SHOW TABLE STATUS LIKE [table name] \ G - - 提供有關非臨時表的信息的表,以及LIKE子句用于獲取表名后顯示的模式。
更多建議: