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
mariadb
group# groupadd mariadb
. - Create
mariadb
user# useradd -r -g mariadb -s /bin/false mariadb
.-
-r, --system
create a system account
-
-g, --gid GROUP
name or ID of the primary group of the new account
-
-s, --shell SHELL
login shell of the new account
-
- Change ownership to
mariadb
for all extracted files# chown -R mariadb:mariadb <MARIADB DIRECTORY>
.
If SELinux is enabled additional modifications may be required.
- Install
mariadb
database# <MARIADB DIRECTORY>/scripts/mysql_install_db --user=mariadb --basedir="<MARIADB DIRECTORY>" --datadir="<DATABASE DIRECTORY>"
-
--user=mariadb
The login username to use for runningmysqld
. Files and directories created bymysqld
will be owned by this user. You must beroot
to use this option. By defaultmysqld
runs using your current login name and files and directories that it creates will be owned by you. -
--basedir=/usr
The path to the MariaDB installation directory. -
--datadir=/var/lib/mariadb
The path to the MariaDB data directory. -
--ldata=path
The path to the MariaDB data directory. Same as --datadir. -
--no-defaults
Don't read default options from any option file. - NOTE Make sure the path to datadir allows +x for the MariaDB user.
-
- Modify ownership to
mariadb
for database# chown -R mariadb:mariadb <DATABASE DIRECTORY>
. - Modify permission for database
chmod -R 775 <DATABASE DIRECTORY>
.- The
mariadb
user and grouprwx
, all other usersrx
.
- The
- Assign user
sudo
privileges tomysqld_safe
# user ALL=(mariadb) NOPASSWD: <MARIADB DIRECTORY>/mysqld_safe
.- An ordinary user requires to
sudo
as usermariadb
in order to start the server.
- An ordinary user requires to
- Modify permission for files that files that are owned by
mariadb
but are allowed to be edited by an other user for administrative purposes, such as the.mariadb.cnf
file; assign a group permission to the file that is shared bymariadb
and 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
rw
for themariadb
user. - 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.frm gtid_slave_pos.ibd innodb_index_stats.frm innodb_index_stats.ibd innodb_table_stats.frm innodb_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 permitted Cannot 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. |