數據庫操作和問題處理

1. 查詢換行顯示

Select * from instances where uuid="6ddf750c-2558-4a32-9591-640a68525337" \G;  

2 刪除

delete from where uuid="6ddf750c-2558-4a32-9591-640a68525337" ;

3 插入記錄

INSERT INTO `instances` VALUES('2019-09-24 01:06:20','2019-09-24 02:32:11',NULL,160,NULL,'e470a2b4b3f54280979e74b412803831','2c9175da1b2b4dadabd9ae443bee570a','d0a89464-ec7e-482e-98d2-6323f18e9235','','','0',NULL,NULL,1,'stopped',4096,4,'win7-1','controller01',NULL,'r-2ml9db2v','2019-09-24 02:32:11',NULL,'yunwei_',NULL,'nova',0,NULL,'controller01',7,NULL,'6ddf750c-2558-4a32-9591-640a68525337',NULL,'/dev/vda',NULL,NULL,'',NULL,NULL,NULL,0,0,0,0,50,0,NULL,'controller01',0,NULL,0,NULL)
 

 

一  不能刪除

1 問題
刪除有外鍵關聯的數據或者表的時候,mysql出現報錯:Cannot delete or update a parent row: a foreign key constraint fails
2 解決方法
SET foreign_key_checks = 0;  // 先設置外鍵約束檢查關閉
drop table mytable;  // 刪除數據,表或者視圖
SET foreign_key_checks = 1; // 開啓外鍵約束檢查,以保持表結構完整性
先關閉外鍵約束,執行刪除操作,然後再開啓外鍵約束

二  mysql -uroot -pxxxx不能進入集羣數據庫

在三臺節點上進行編輯
vi /etc/my.cnf.d/openstack.cnf
加入
[mysqld]
skip-grant-tables

三臺節點上執行如下的命令
use mysql;
update user set password=PASSWORD("mysql_pass") where user='root';
flush privileges;

再去掉skip-grant-tables,重新啓動數據庫
先關閉次節點systemctl stop mariadb.service
關閉主節點,採取殺掉進程的方式
啓動主節點 /usr/libexec/mysqld --wsrep-new-cluster --user=root &
啓動次節點   systemctl start mariadb.service

三   在重新安裝數據庫的時候,keystone同步數據之後不報錯,查看日誌有錯誤。

集羣三個節點上,遠程禁止root用戶登錄改爲 No 也就是第四次
mysql_secure_installation

重新安裝數據庫還需要:
# 初始化admin用戶(管理用戶)與密碼,3種api端點,服務實體可用區等
[root@controller01 ~]# keystone-manage bootstrap --bootstrap-password admin_pass \
  --bootstrap-admin-url http://controller:35357/v3/ \
  --bootstrap-internal-url http://controller:5000/v3/ \
  --bootstrap-public-url http://controller:5000/v3/ \
  --bootstrap-region-id RegionTest
重新創建domain, projects, users, 與roles
glance按照文檔安裝即可

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章