CREATE DATABASE IF NOT EXISTS yourdbname DEFAULT CHARSET utf8 COLLATE utf8_general_ci; 在tigase中,發送消息有文本的形式,比如發送emoji表情, 編碼必須採用 utf8mb4 , utf8mb4 is a ...
CREATE DATABASE IF NOT EXISTS yourdbname DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
在tigase中,發送消息有文本的形式,比如發送emoji表情, 編碼必須採用 utf8mb4 , utf8mb4 is a utf8 character set, which was added to MySQL in version 5.3.3, that fully supports unicode. utf8mb4是一種可支持4個位元組UTF編碼,一個字元最多能有4位元組,所以能支持更多的字元集。比如可以支持emoji表情。
mysql> show create table msg_history;
+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| msg_history | CREATE TABLE `msg_history` (
`msg_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`expired` datetime DEFAULT NULL,
`sender_uid` bigint(20) unsigned DEFAULT NULL,
`receiver_uid` bigint(20) unsigned NOT NULL,
`msg_type` int(11) NOT NULL,
`message` text CHARACTER SET utf8mb4 NOT NULL,
UNIQUE KEY `msg_id` (`msg_id`),
KEY `expired` (`expired`),
KEY `sender_uid` (`sender_uid`,`receiver_uid`),
KEY `receiver_uid` (`receiver_uid`,`sender_uid`)
) ENGINE=InnoDB AUTO_INCREMENT=110488 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC |
另外:
CREATE TABLE `qcloud_sms_template` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `ctime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(`id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
只有 mysql 5.6.5+ 才支持 DATETIME類型
所以安裝 mysql 的時候 必須升級到 5.6.5 以上版本。
centos 上安裝mysql:
service mysqld stop
yum remove mysql mysql-*
查看是否有殘餘的mysq,輸入命令:
yum list installed | grep mysql
如果有,可輸入命令刪除:
rum remove mysql-libs
下載安裝最新的rpm文件
rpm -Uvh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
安裝MySQL,輸入命令:
yum install mysql-community-server
問題:
[root@host-192-168-1-36 software]# mysql -utigase -ptigase
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'tigase'@'localhost' (using password: YES)
解決方法:
1、先修改 root 密碼:
用SET PASSWORD命令
mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
或者用UPDATE直接編輯user表
mysql -u root
mysql> use mysql;
mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';
mysql> FLUSH PRIVILEGES;
用root 賬號登錄mysql, 查看mysql 資料庫 中 的 user 表,是否有 tigase賬號, 如果沒有,則執行:
GRANT USAGE ON *.* TO 'tigase'@'localhost' IDENTIFIED BY 'tigase';
2)授權法。例如,你想wow使用mypassword從任何主機連接到mysql伺服器的話。
GRANT ALL PRIVILEGES ON *.* TO 'wow'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
如果你想只允許用戶wow從ip為192.168.83.56的主機連接到192.168.11.12的mysql伺服器,並使用mypassword作為密碼
GRANT ALL PRIVILEGES ON *.* TO 'wow'@'192.168.83.56' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES
如果用tigase賬號登錄mysql 後,無法使用 tigasedb 資料庫:
mysql> use tigasedb;
ERROR 1044 (42000): Access denied for user 'tigase'@'localhost' to database 'tigasedb'
查看user表:
| localhost | tigase | *04B3CD6E8CDAF8E0494A9E3076FDCDCBD155A98A | N | N | N | N | N | N | N | N | N | N
許可權都是 N,
解決辦法:
使用 root 賬號登錄mysql ,
mysql> use mysql;
mysql> GRANT ALL ON *.* TO 'tigase'@'localhost';
mysql> FLUSH PRIVILEGES;
再次查看 user表許可權,已都有許可權:
| tigase | *04B3CD6E8CDAF8E0494A9E3076FDCDCBD155A98A | Y | Y | Y | Y | Y | Y | Y | Y | Y
tigase可以使用 tigasedb 。
mysqldump -u root -p testdb > testdb.sql (不包括存儲過程和函數) mysqldump -u root -p -R testdb > testdb.sql (**包括存儲過程和函數**) mysql 在導入大量數據時,為了加快導入速度,可以
②在導入數據前執行SET UNIQUE_CHECKS=0,關閉唯一性校驗,在導入結束後執行SET UNIQUE_CHECKS=1,恢復唯一性校驗,可以提高導入的效率。
③如果應用使用自動提交的方式,建議在導入前執行SET AUTOCOMMIT=0,關閉自動提交,導入結束後再執行SET AUTOCOMMIT=1,打開自動提交,也可以提高導入的效率。
為了防止 使用 source 命令導入,CRT斷開導致導入中止的情況,可以使用 啟用後臺進程導入: mysql -uroot -ppassword -Ddbname < tigase.sql &