備忘 MariaDB/MySQL 操作步驟

系統:ubuntu 16.04


Reset root password on Calera Cluster MariaDB(20180608)

忘記mysql root 密碼時的做法如下:
設定skip-grant-tables

$ sudo mysqld_safe --skip-grant-tables &
$ vi /etc/mysql/my.conf
add skip-grant-tables

restart mysql:
server mysql restart

execute update sql:

mysql>use mysql;

MariaDB [mysql]>; SELECT user, plugin FROM user;
+------+-------------+
| user | plugin |
+------+-------------+
| root | unix_socket |
| root | unix_socket |
| root | unix_socket |
| root | unix_socket |
+------+-------------+

UPDATE user SET plugin=""; // without WHERE clause
UPDATE user SET passwor=PASSWORD("mys_passwd") WHERE user="root"
FLUSH PRIVILEGES;

然後再把skip-grant-table拿掉

重新restart mysql即可…


Calera Clustea MariaDB not sync(20180508)

Q: calera cluster mariadb not sync other server!!

A:

輸入指令重置/var/lib/mysql 和刪除/var/lib/mysql/grastate.dat

然後重新mysql服務即可

#mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

參考:https://serverfault.com/questions/812719/mysql-mariadb-not-starting