Showing posts with label MariaDB. Show all posts
Showing posts with label MariaDB. Show all posts

Thursday, 8 November 2018

MySQL going down due to insufficient memory

seems that our droplets doesnt have enogh memory some times and mysql cant allocate what it needs and crash, so we need to create a swap space to help this.
this is what I did:


On the command line
root@myserver:~# dd if=/dev/zero of=/swap.dat bs=1024 count=512k
root@myserver:~# mkswap /swap.dat
root@myserver:~# swapon /swap.dat
root@myserver:~# vim /etc/fstab
vim is started to edit, add the following to the end of /etc/fstab file
/swap.dat      none    swap    sw      0       0

Then, edit the mysql config file
root@myserver:~# vim /etc/mysql/my.cnf
And add this under [mysqld]
innodb_buffer_pool_size=64M

Finally reload mysql
root@myserver:~#  service mysqld reload

Remote access to MariaDB


Edit my config file (vi /etc/mysql/my.cnf) :

Mark off line “bind-address 127.0.0.x”

Insert new line below as “bind-address 0.0.0.0”



CREATE 12 USER ‘user_remote_R_only’@‘localhost’ IDENTIFIED BY ‘myStrongeSTpassword’;

CREATE USER ‘user_remote_R_only’@’%’ IDENTIFIED BY ‘myStrongeSTpassword’;

GRANT SELECT ON *.* TO ‘user_remote_R_only’@‘localhost’;

GRANT SELECT ON *.* TO ‘user_remote_R_only’@’%’;

flush privileges;



Restart the MYSQL Server sudo service mysql restart