installation
shell> yum install mariadb-server -y
Configuration
# Modify the file / etc / my.cnf [mysqld]
datadir = / mydata / the Data / MySQL
Character-the SET-Server = utf8 # default character set (reportedly utf8mb4 real UTF8 character set )
collation utf8_general_ci-Server = # The default sort rule (ibid corresponds utf8mb4_general_ci)
[the mysqld_safe] log -error = / mydata / logs / MariaDB / mariadb.log
# 创建必要的目录
shell> mkdir -p /mydata/data/mysql /mydata/logs/mariadb
shell> chown -R mysql:mysql /mydata/data/mysql
shell> chown -R mysql:mysql /mydata/logs/mariadb
start up
shell> systemctl enable mariadb
shell> systemctl start mariadb
initialization
shell> mysql_secure_installation the Enter Current password for root (the Enter for none): # default is empty, directly enter the Set root password ? [the Y-/ the n-] # the Y-, set the root password New password: Re - the Enter new new password: the Remove the Users Anonymous ? [the Y-/ the n-] # Y, the test environment can be the n- Disallow root the Login remotely? [the Y-/ the n-] # generally Y, can only restrict root Log on the Remove the test Database and Access to IT ? [the Y-/ the n-] # the Y- , the test environment can be the n- Reload the Tables Privilege now ? [the Y-/ the n-] The Y #, commencement initializing the shell > MySQL -uroot--p after # password, connect to the database
Library Table
MariaDB> Create Database XYZ; # create a database XYZ
MariaDB> Show Databases; # Display all the database
MariaDB> use XYZ; # access to the database XYZ
MariaDB [XYZ]> Create Table X (ID int, name VARCHAR (25)); # Create table X
MariaDB [xyz]> iNSERT INTO X values (. 1, 'John Doe'); # insert data
MariaDB [xyz]> SELECT * from X; # query data
MariaDB [xyz]> desc X; # Display structure
MariaDB [xyz ]> Show the create database xyz; # view creation statements database
MariaDB [xyz]> Show the create the table the X-; # View the table creation statements
MariaDB> drop the table xyz.x; # delete tables
MariaDB> database drop xyz; # delete the database
Users and Permissions
MariaDB> the Create the User 'the Uu' @ '%' IDENTIFIED by 'pwd'; # create user uu, password is pwd;% representation can log on from any machine, you can define the host name or IP, will be different here as another user
MariaDB > the SELECT the user, Host from the mysql.user; # view all users
MariaDB> Show Grants for 'the Uu' @ '%'; # view the user's permission; default USAGE, arguably without any permission
MariaDB> grant all on *. to * 'the Uu' @ '%'; # grant full permissions to all tables in all databases; all means all rights; first * indicates all databases; second * means all tables
. MariaDB> revoke all on * * from 'the Uu' @ '%'; # reclaim authority
MariaDB> grant select ON xyz.x to 'the Uu' @ '%'; # x tables grant database xyz select privilege
MariaDB> rename user 'uu' @ '%' to 'EE' @ 'localhost'; # modify the user name
MariaDB> password for SET 'EE' @ 'localhost' = password ( '123'); # change password
MariaDB> drop the User 'EE' @ 'localhost'; # delete user
over