Howto mariadb server: Difference between revisions

From Vidalinux Wiki
Jump to navigation Jump to search
Line 23: Line 23:
  mysql -uroot -p${ROOT_PASS} -e "GRANT ALL PRIVILEGES ON ${DBNAME}.* TO '${DBUSER}'@'%' IDENTIFIED BY '${DBPASS}';"
  mysql -uroot -p${ROOT_PASS} -e "GRANT ALL PRIVILEGES ON ${DBNAME}.* TO '${DBUSER}'@'%' IDENTIFIED BY '${DBPASS}';"
connect to mariadb with user:
connect to mariadb with user:
  mysql -u mydbuser -pmydbpassword
  mysql -u ${DBUSER} -p${DBPASS}

Revision as of 21:42, 12 August 2020

install mariadb on archlinux

install the package:

pacman -S mariadb

create the datadir:

mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

secure your mariadb installation:

mysql_secure_installation

start and enable mariadb service:

systemctl start mariadb
systemctl enable mariadb

connect to your database server:

mysql -u root -h localhost -p

mariadb administration

set this variables on your shell or script:

ROOT_PASS="mysqlrootpassword"
DBUSER=mydbuser
DBNAME=mydbname
DBPASS=mydbpassword

create the database:

mysql -uroot -p${ROOT_PASS} -e "CREATE DATABASE ${DBNAME};"

create the user and privileges to access from localhost and remote:

mysql -uroot -p${ROOT_PASS} -e "GRANT ALL PRIVILEGES ON ${DBNAME}.* TO '${DBUSER}'@'localhost' IDENTIFIED BY '${DBPASS}';"
mysql -uroot -p${ROOT_PASS} -e "GRANT ALL PRIVILEGES ON ${DBNAME}.* TO '${DBUSER}'@'%' IDENTIFIED BY '${DBPASS}';"

connect to mariadb with user:

mysql -u ${DBUSER} -p${DBPASS}