mariadb - bunnyamin/bunnix GitHub Wiki
| Command | Example |
|---|---|
Install root
|
# './bin/mysqladmin' -u root [-h <HOSTNAME>] password '<PASSWORD>' |
| User, create, ordinary |
CREATE USER '<USER>'@'<HOST>' [IDENTIFIED BY '<PASSWORD>'];GRANT CREATE, DROP, DELETE, INSERT, SELECT, UPDATE ON * . * TO '<USER>'@'<HOST>';GRANT ALL PRIVILEGES ON * . * TO ''<USER>'@'<HOST>';GRANT SHUTDOWN ON * . * TO ''<USER>'@'<HOST>';FLUSH PRIVILEGES; |
| User, rename | RENAME user '<user>' TO '<USER>'@'<HOST>'; |
| User, delete | DROP USER '<USER>'@'<HOST>'; |
- Create
mariadbgroup# groupadd mariadb. - Create
mariadbuser# useradd -r -g mariadb -s /bin/false mariadb.-
-r, --systemcreate a system account -
-g, --gid GROUPname or ID of the primary group of the new account -
-s, --shell SHELLlogin shell of the new account
-
- Change ownership to
mariadbfor all extracted files# chown -R mariadb:mariadb <MARIADB DIRECTORY>.
If SELinux is enabled additional modifications may be required.
- Install
mariadbdatabase# <MARIADB DIRECTORY>/scripts/mysql_install_db --user=mariadb --basedir="<MARIADB DIRECTORY>" --datadir="<DATABASE DIRECTORY>"-
--user=mariadbThe login username to use for runningmysqld. Files and directories created bymysqldwill be owned by this user. You must berootto use this option. By defaultmysqldruns using your current login name and files and directories that it creates will be owned by you. -
--basedir=/usrThe path to the MariaDB installation directory. -
--datadir=/var/lib/mariadbThe path to the MariaDB data directory. -
--ldata=pathThe path to the MariaDB data directory. Same as --datadir. -
--no-defaultsDon't read default options from any option file. - NOTE Make sure the path to datadir allows +x for the MariaDB user.
-
- Modify ownership to
mariadbfor database# chown -R mariadb:mariadb <DATABASE DIRECTORY>. - Modify permission for database
chmod -R 775 <DATABASE DIRECTORY>.- The
mariadbuser and grouprwx, all other usersrx.
- The
- Assign user
sudoprivileges tomysqld_safe# user ALL=(mariadb) NOPASSWD: <MARIADB DIRECTORY>/mysqld_safe.- An ordinary user requires to
sudoas usermariadbin order to start the server.
- An ordinary user requires to
- Modify permission for files that files that are owned by
mariadbbut are allowed to be edited by an other user for administrative purposes, such as the.mariadb.cnffile; assign a group permission to the file that is shared bymariadband the user, for example,users.
-
$ sudo -u mariadb <MARIADB DIRECTORY>/mysqld_safe --defaults-file="~/.mariadb.cnf" --ledir="/mariadb/bin/"- NOTE Ensure the path to log allows
rwfor themariadbuser. - The defaults-file must come before
ledir.
- NOTE Ensure the path to log allows
| Event | Error | Cause | Remedy |
|---|---|---|---|
bin/mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory |
Build libncurses.so.5. and ln -s /ncurses/libncurses.so.5 /usr/lib/libncurses.so.5. |
||
Cannot open table mysql/(innodb_(index_stats|table_stats) | s lave_(master_info|relay_log_info|worker_info) |
Delete all binlogs. (1) Shutdown server. (2) Delete any and all:gtid_slave_pos.frmgtid_slave_pos.ibdinnodb_index_stats.frminnodb_index_stats.ibdinnodb_table_stats.frminnodb_table_stats.ibd(3) Start server mysql_upgrade --defaults-file=mariadb.cnf. (4) Restart server. |
||
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) |
Reset root password. (1) Stop mysqld, and restart with skip grant mysqld_safe --defaults-file=~/mariadb.cnf --ledir=<MARIADB DIRECTORY>/bin --skip-grant-tables. (2) Start mariadb, and update root password mysql --defaults-file=~/mariadb.cnf.MariaDB [(none)]> use mysql;MariaDB [mysql]> UPDATE user SET password=PASSWORD('<NEW PASSWORD>') WHERE User='root';MariaDB [mysql]> FLUSH PRIVILEGES;MariaDB [mysql]> quit;(3) Stop server running skip grant, start it as usual. |
||
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2 'No such file or directory') |
|||
mysql_install_db |
# chown: changing ownership of '<DATABASE DIRECTORY>': Operation not permittedCannot change ownership of the database directories to the 'mysql' user. Check that you have the necessary permissions and try again.
|
Executing mysql_install_db as ordinary user. |