`

MariaDB_installing,starting and stoping,configuring,logging in

 
阅读更多

Installing MariaDB Binary Tarballs

via: https://mariadb.com/kb/en/installing-mariadb-binary-tarballs/

 

MariaDB Binary tarballs are named following the pattern: mariadb-VERSION-OS.tar.gz. Be sure to downloadthe correct version for your machine.

Note: Some binary tarballs are marked '(GLIBC_2.14)' or '(requires GLIBC_2.14+)'. These binaries are built the same as the others, but on a newer build host, and they require GLIBC 2.14 or higher. Use the other binaries for machines with older versions of GLIBC installed.

To install the binaries, unpack the distribution into the directory of your choice and run the mysql_install_dbscript.

In the example below we install MariaDB in the /usr/local/mysql directory (this is the default location for MariaDB for many platforms). However any other directory should work too.

We install the binary with a symlink to the original name. This is done so that you can easily change MariaDB versions just by moving the symlink to point to another directory.

NOTE: For MariaDB 5.1.32 only the line "./scripts/mysql_install_db --user=mysql" should be changed to "./bin/mysql_install_db --user=mysql"

Ensure you use the correct my.cnf files

MariaDB searches for the configuration files '/etc/my.cnf' (on some systems '/etc/mysql/my.cnf') and '~/.my.cnf'. If you have an old my.cnf file (maybe from a system installation of MariaDB or MySQL) you need to take care that you don't accidentally use the old one with your new binary .tar installation.

The normal solution for this is to ignore the my.cnf file in /etc when you use the programs in the tar file.

This is done by creating your own .my.cnf file in your home directory and telling mysql_install_dbmysqld_safe and possibly mysql (the command-line client utility) to only use this one with the option '--defaults-file=~/.my.cnf'. Note that this has to be first option for the above commands!

Installing MariaDB as root in /usr/local/mysql

If you have root access to the system, you probably want to install MariaDB under the user and group 'mysql' (to keep compatibility with MySQL installations):

groupadd mysql
useradd -g mysql mysql
cd /usr/local
tar -zxvpf /path-to/mariadb-VERSION-OS.tar.gz
ln -s mariadb-VERSION-OS mysql
cd mysql
./scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data

The symlinking with ln -s is recommended as it makes it easy to install many MariaDB version at the same time (for easy testing, upgrading, downgrading etc).

If you are installing MariaDB to replace MySQL, then you can leave out the call to mysql_install_db. Instead shut down MySQL. MariaDB should find the path to the data directory from your old /etc/my.cnf file (path may vary depending on your system).

To start mysqld you should now do:

./bin/mysqld_safe --user=mysql &
or
./bin/mysqld_safe --defaults-file=~/.my.cnf --user=mysql &

To test connection, modify your $PATH so you can invoke client such as mysql, mysqldump, etc.

export PATH=$PATH:/usr/local/mysql/bin/

You may want to modify your .bashrc or .bash_profile to make it permanent.

Installing MariaDB as not root in any directory

Below, change /usr/local to the directory of your choice.

cd /usr/local
gunzip < /path-to/mariadb-VERSION-OS.tar.gz | tar xf -
ln -s mariadb-VERSION-OS mysql
cd mysql
./scripts/mysql_install_db --defaults-file=~/.my.cnf

If you have problems with the above gunzip command line, you can instead, if you have gnu tar, do:

tar xfz /path-to/mariadb-VERSION-OS.tar.gz

To start mysqld you should now do:

./bin/mysqld_safe --defaults-file=~/.my.cnf &

Auto start of mysqld

You can get mysqld (the MariaDB server) to autostart by copying the file mysql.server file to the right place.

cp support-files/mysql.server /etc/init.d/mysql.server

 

The exact place depends on your system. The mysql.server file contains instructions of how to use and fine tune it.

Post installation

After this, remember to set proper passwords for all accounts accessible from untrusted sources, to avoid exposing the host to security risks! Also consider using the mysql.server to start MariaDB automatically when your system boots.

Our MariaDB binaries are similar to the Generic binaries available for the MySQL binary distribution. So for more options on using these binaries, the MySQL 5.5 manual entry on installing generic binaries can be consulted.

For details on the exact steps used to build the binaries, see the compiling MariaDB section of the KB.

 

 

Starting and Stopping MariaDB Automatically

via: https://mariadb.com/kb/en/iniciando-e-parando-mariadb-automaticamente/

 

When running MariaDB in a server environment it is almost always desirable to have MariaDB start automatically when the server is powered on, for it to stay running while the server is running, and for it to be shutdown gracefully when the server is shut down.

The actual MariaDB server binary is called mysqld. Like other MariaDB binaries, it is so named to preserve compatibility with upstream MySQL.

You have the option of starting the mysqld server several different ways:

  1. Run or invoke mysqld itself. An example of doing this is described more in Running MariaDB from the Source Directory.
  2. Use the mysqld_safe startup script
  3. Use the mysql.server startup script

The mysql.server script starts mysqld by first changing to the MariaDB install directory and then calling mysqld_safe. Adding an appropriate user line to the [mysqld] group in your my.cnf file will cause the server to be run as that user.

If you have installed MariaDB to a non-standard location, you may need to edit the mysql.server script to get it to work right.

mysql.server works as a standard SysV-style init script. As such you use the script with start and stoparguments like so:

mysql.server start
mysql.server stop

To configure MariaDB to start and stop automatically on Linux using the mysql.server script you need to add it to your distribution's init system, usually by copying it to /etc/init.d/ and then creating specially named symlinks in the appropriate /etc/rcX.d/ directories (where 'X' is a number between 0 and 6).

In the examples below we will follow the historical convention of renaming the mysql.server script to 'mysql' when we copy it to /etc/init.d/.

The first step for most Linux distributions is to copy the mysql.server script to /etc/init.d/ and make it executable:

cd /path/to/your/mariadb-version/support-files/
cp mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql

Now all that is needed is to create the specially-named symlinks. On both RPM and Debian-based Linux distributions there are tools which do this for you. Consult your distribution's documentation if neither of these work for you and follow their instructions for generating the symlinks or creating them manually.

On RPM-based distributions (like Fedora and CentOS), you use chkconfig:

chkconfig --add mysql
chkconfig --level 345 mysql on

On Debian-based distributions you use update-rc.d:

update-rc.d mysql defaults

On FreeBSD, the location for startup scripts is /usr/local/etc/rc.d/ and when you copy the mysql.serverscript there you should rename it so that it matches the *.sh pattern, like so:

cd /path/to/your/mariadb/support-files/
cp mysql.server /usr/local/etc/rc.d/mysql.server.sh

As stated above, consult your distribution's documentation for more information on starting services like MariaDB at system startup.

See mysqld startup options for information on configuration options for mysqld.

 

Configuring MariaDB with my.cnf

via: https://mariadb.com/kb/en/configuring-mariadb-with-mycnf/

 

The my.cnf file allows you to configure MariaDB to run the way you want it. Most of the server system variablescan be set in the my.cnf file, although usually only a few are, and the rest simply take their default values.

Depending on how you've installed MariaDB, the my.cnf may be in a number of places, or it may not exist at all.

Location in Linux, Unix, Mac

On a Linux, Unix or Mac server, MariaDB looks for the my.cnf file in the following locations:

Location Scope
/etc/my.cnf Global
/etc/mysql/my.cnf Global
SYSCONFDIR/my.cnf Global
$MYSQL_HOME/my.cnf Server
defaults-extra-file File specified with --defaults-extra-file=path, if any
/.my.cnf User
  • SYSCONFDIR is the directory specified with the CMake SYSCONFDIR option when MariaDB was built, by default etc under the compiled-in installation directory.
  • MYSQL_HOME is the environment variable containing the path to the directory holding the server-specific my.cnf file. If MYSQL_HOME is not set, and the server is started with mysqld_safe, MYSQL_HOME is set as follows:
    • If there is a my.cnf file in the MariaDB data directory, but not in the MariaDB base directory, MYSQL_HOME is set to the MariaDB data directory.
    • Else, MYSQL_HOME is set to the MariaDB base directory.

Location in Windows

On Windows, my.ini can be used as well as my.cnf, and MariaDB looks in the following locations.

Location Scope
%PROGRAMDATA%\MySQL\MySQL Server x.x\my.cnf Global (x.x refers to the version)
%WINDIR%\my.cnf Global
C:\my.cnf Global
INSTALLDIR\my.cnf Global
defaults-extra-file File specified with --defaults-extra-file=path, if any
  • %PROGRAMDATA% is the file system directory containing application data for all the host's users. It defaults to C:\ProgramData on modern versions of Windows, or toC:\Documents and Settings\All Users\Application Data on Windows XP and before.
  • %WINDIR% is the Windows directory, usually C:\WINDOWS. To find its specific value on your system, use:
C:\> echo %WINDIR%
  • INSTALLDIR is the MariaDB installation directory from using the Windows installer, usuallyC:\PROGRAMDIR\MySQL\MySQL 5.5 Server, where PROGRAMDIR in turn is the programs directory, usuallyProgram Files

my.cnf hierarchy

MariaDB will look in all of the above locations, in order, even if has already found a my.cnf file, and it's possible for more than one my.cnf file to exist. For example, you can have a my.cnf file in /etc/mysql/my.cnf with global settings for all servers, and then another my.cnf file in the user's home directory, /my.cnf, which will add further (or overwrite) settings specific only to that user.

If no my.cnf file is found, the default values are used for all variables. See server system variables for a full list of all server variables and their default values.

You will most likely also find sample my.cnf files called my-huge.cnf.shmy-large.cnf.sh,my-medium.cnf.sh, and my-small.cnf.sh. You can choose one of these appropriate for your type of installation, and copy and rename it as your my.cnf file.

 

 

mysqld configuration files and groups

via: https://mariadb.com/kb/en/mysqld-configuration-files-and-groups/

 

Default options are generally read from the following files in the given order:

  1. /etc/my.cnf
  2. /etc/mysql/my.cnf
  3. my.cnf in the DEFAULT_SYSCONFDIR specified during the compilation
  4. my.cnf in the path, specified in the environment variable MYSQL_HOME (if any)
  5. the file specified in --defaults-extra-file (if any)
  6. user-home-dir/.my.cnf

For an exact list for your system execute mysqld --help --verbose. The full file list will be near the beginning of the output.

This page lists the different mysqld startup options you can use.

mysqld reads the following my.cnf sections:

  1. [mysqld]
  2. [server]
  3. [mysqld-X.X]
  4. [mariadb]
  5. [mariadb-X.X]
  6. [client-server] -- (MariaDB 5.3 and higher)

X.X in the examples above refer to the base (major.minor) version of the server. For example in MariaDB 5.5.32 the base version is 5.5.

For a full list of mysqld options and their current values (based on your local my.cnf), do:

mysqld --print-defaults
mysqld --help --verbose

Global Options

The following options determine how mysqld handles option files. They may be given as the first argument:

Option Description
--print-defaults Print the program argument list and exit.
--no-defaults Don't read default options from any option file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.

MariaDB Options

The full sets of options are described here.

Minimal my.cnf file

Here is a minimal my.cnf file you can install in ~/.my.cnf to test MariaDB 5.3. (For 5.2, you need to copy the section [client-server] to [client] and [mysqld]).

[client-server]
# Uncomment these if you want to use a nonstandard connection to MariaDB
#socket=/tmp/mysql.sock
#port=3306

# This will be passed to all MariaDB clients
[client]
#password=my_password

# The MariaDB server
[mysqld]
# Directory where you want to put your data
data=/usr/local/mysql/var
# Directory for the errmsg.sys file in the language you want to use
language=/usr/local/mysql/share/mysql/english
# Create a file where the InnoDB/XtraDB engine stores it's data
loose-innodb_data_file_path = ibdata1:1000M
loose-innodb_file_per_table

# This is the prefix name to be used for all log, error and replication files
log-basename=mysqld

# Enable logging by default to help find problems
general-log
log-slow-queries

The following my.cnf example files are included with MariaDB. Examine them to see more complete examples of some of the many ways to configure MariaDB.

  • my-small.cnf
  • my-medium.cnf
  • my-large.cnf
  • my-huge.cnf

The above example files can usually be found in one of the following directories:

  • source-file-path/support-files
  • mysql-install-path/share/mysql (e.g. /usr/local/mysql/share/mysql)

 

 

 

Logging In

via: https://mariadb.com/kb/en/a-mariadb-primer-02-logging-in/

 

Login to the server that has access to the MariaDB database you want to use. Often this is the same machine that is hosting the database, sometimes it isn't.

To connect to the database type:

mysql -u username -p -h host databasename

ps:if this is the same machine that is hosting the database and you don't wanna identify which database you will user,you can type mysql -u username -p;

     if you have a user named 'mysql' with no password,you can type mysql -u mysql.

Replace username with your database username, host with the URI of the database server (if the database is on the local host you can enter 'localhost'), and databasename with the name of the database you want to access. When prompted to enter your password, enter it.

If the copy of MariaDB that you want to access is on the same machine as you, you can ignore the "-h host" argument. The mysql program will assume that you are logging in to a local database.

If your mysql username is the same as your computer login name, you can leave the "-u username" argument off.

If your login is successful you should see something that looks similar to this:

daniel@mycomputer:~$ mysql -u daniel -p -h localhost test
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.2.0-MariaDB-beta Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [test]>

The 'MariaDB [test]>' prompt is what we are interested in. The is where you will enter in all of your SQL statements. More about those on the next page in the primer. For now, let me explain the parts of the prompt:

  1. The "MariaDB" part tells you that you are connected to a MariaDB database.
  2. The word between the brackets ('[' and ']') is the name of the database you are connected to. In the example above we are connected to the 'test' database.
  3. The '>' is the final bit of the prompt. It exists to tell you that the program is ready and waiting for you to enter in your commands.
分享到:
评论

相关推荐

    navicat150_mariadb_cs_x64.exe

    navicat150_mariadb_cs_x64.exe 一款专门为mariadb 数据库使用的navicat工具

    Mariadb_install_win.rar

    标题"Mariadb_install_win.rar"表明这是一个关于在Windows操作系统上安装MariaDB的压缩包文件,特别是通过批处理(BAT)脚本来实现一键安装的过程。MariaDB是一个开源的关系型数据库管理系统,它是MySQL的一个分支,...

    (34条消息) CentOS 7 安装mariadb_centos7安装mariadb_托塔雨天王的博客-CSDN博客.mhtml

    (34条消息) CentOS 7 安装mariadb_centos7安装mariadb_托塔雨天王的博客-CSDN博客.mhtml

    mariadb_deploy.sh

    Centos7自动安装mariadb并设置密码允许用户远程登录脚本

    Automatic_installation_for_MariaDB_on_Linux(MariaD_ansible-

    Automatic_installation_for_MariaDB_on_Linux(MariaD_ansible-mariadb

    navicat110_mariadb_cs_x86.zip

    标题中的"navicat110_mariadb_cs_x86.zip"指向的是一款专为32位Windows系统设计的Navicat for MariaDB的11.0版本。这款工具以其直观的界面和强大的功能,让数据库管理变得轻松而高效。 首先,Navicat for MariaDB是...

    Mariadb_install_linux.rar

    本文将详细介绍如何使用提供的shell脚本"Mariadb_install_linux"在CentOS 7上进行MariaDB的安装。MariaDB是MySQL的一个分支,由MySQL的创始人创建,旨在保持开源和不受Oracle公司控制。 1. **CentOS 7系统准备**: ...

    mariadb_10.0.14 龙芯cpu 安装包

    mariadb_10.0.14 龙芯cpu 安装包,已经适配了3A3000,3a4000. 安装后需要命令好启动。 安装路径为\usr\local\mysql。 仅供研究使用,请勿商用。

    mariadb_v10.5.8_winx64_itmop.com.zip

    这个“mariadb_v10.5.8_winx64_itmop.com.zip”压缩包包含了在Windows 64位系统上运行的MariaDB 10.5.8版本。 MariaDB 10.5.8是该数据库系统的一个重要版本,提供了许多新特性和改进。以下是一些关键知识点: 1. *...

    MariaDB_Query_Pro_V6.0.0.1

    A simple tool, which can help you bring all data stored in Excel Data Files into MariaDB, and then you can handle your data in MariaDB via this tool through Excel. Just try it!

    NetBackup82_MariaDB_AdminGuide.pdf

    VERITAS NetBackup 8.2 中文管理指南是 Veritas Technologies LLC 发布的一份关于 VERITAS NetBackup for MariaDB 的管理指南,该指南适用于 Windows 和 Linux 平台,版本为 8.2。本指南最后一次更新时间为 2019 年 ...

    mariadb_cluster1:Docker 容器上的 MariaDB 集群

    Docker pull jsdizon/mariadb_cluster1 创建图像。 git clone https://github.com/jsdizon/mariadb_cluster1.git docker build -t mariadbcluster . 单个 Docker 服务器 假设我们有一个 docker 服务器,我们将...

    NetBackup812_MariaDB_AdminGuide.pdf

    Veritas NetBackup 8.1.2 是一款强大的数据保护解决方案,特别针对MariaDB数据库管理系统设计的管理员指南。本指南提供了在Windows和Linux操作系统上管理MariaDB备份的详细信息,帮助用户确保数据的安全性和可恢复性...

    navicat150_mariadb_en.dmg navicat-for-mariadb: 15.0.12

    用于MariaDB的Navicat为MariaDB数据库管理和开发提供了本机环境。连接到本地/远程MariaDB服务器,并与Amazon RDS兼容。适用于MariaDB的Navicat支持大多数附加功能,例如新的存储引擎,微秒,虚拟列等。

    NetBackup83_MariaDB_AdminGuide.pdf

    Veritas NetBackup 8.3 是一款强大的数据保护解决方案,专为Windows和Linux环境设计,旨在为MariaDB数据库提供安全且高效的备份与恢复服务。MariaDB是一款开源的关系型数据库管理系统,广泛应用于各种业务场景,因此...

    NetBackup811_MariaDB_AdminGuide.pdf

    Veritas NetBackup 8.1.1 for MariaDB Administrator's Guide是专为在Windows和Linux平台上管理和保护MariaDB数据库设计的一份详细指南。Veritas Technologies LLC是一家知名的备份和恢复解决方案提供商,其...

    mariadb_mysql_CH_ZN.txt

    Wamp数据库帮助中文

    CENTOS7.X下MariaDB_Galera集群安装及配置真实可用

    按照解压后Galera.txt中的操作一步步做,20分钟安装配置好CENTOS7.X(现本人在用的是7.6)下的MariaDB 10.3.12(最新稳定版2019.1.7发布)的Galera 25.24的双主集群。 MariaDB 为Mysql的开原版,百分百兼容Mysql,双...

Global site tag (gtag.js) - Google Analytics