MySQL數(shù)據(jù)庫操作常用命令小結(jié)
創(chuàng)建數(shù)據(jù)庫
最簡單的方式:
CREATE DATABASE my_db;
或者是:
CREATE DATABASE IF NOT EXISTS my_db;
創(chuàng)建utf8編碼的數(shù)據(jù)庫:
CREATE DATABASE IF NOT EXISTS my_db default character set utf8 COLLATE utf8_general_ci;
那么在這個數(shù)據(jù)庫下創(chuàng)建的所有數(shù)據(jù)表的默認(rèn)字符集都會是utf8了,注意后面這句話 "COLLATE utf8_general_ci",大致意思是在排序時(shí)根據(jù)utf8變碼格式來排序。
查看數(shù)據(jù)庫列表:
show databases;
使用數(shù)據(jù)庫:
use my_db;
查看數(shù)據(jù)庫默認(rèn)編碼:
show variables like 'character_set_%'
+--------------------------+-------------------------------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.5.28-linux2.6-i686/share/charsets/ |
+--------------------------+-------------------------------------------------------+
可以看到character_set_database是lantin1.
修改數(shù)據(jù)庫編碼:
alter database my_db character set latin1;
刪除數(shù)據(jù)庫:
drop database my_db;
或者是:
drop database IF EXISTS my_db;
- MySQL數(shù)據(jù)庫備份和還原的常用命令小結(jié)
- MySQL操作數(shù)據(jù)庫和表的常用命令新手教程
- MySQL數(shù)據(jù)庫維護(hù)中監(jiān)控所用到的常用命令
- MySQL 數(shù)據(jù)庫常用命令 簡單超級實(shí)用版
- MySQL數(shù)據(jù)庫管理常用命令小結(jié)
- MySQL常用命令 MySQL處理數(shù)據(jù)庫和表的命令
- MYSQL 數(shù)據(jù)庫導(dǎo)入導(dǎo)出命令
- Mysql數(shù)據(jù)庫的一些命令
- MySQL優(yōu)化全攻略-相關(guān)數(shù)據(jù)庫命令
- mysqldump命令導(dǎo)入導(dǎo)出數(shù)據(jù)庫方法與實(shí)例匯總
- MySQL命令行導(dǎo)出導(dǎo)入數(shù)據(jù)庫實(shí)例詳解
- MySQL數(shù)據(jù)庫基礎(chǔ)入門之常用命令小結(jié)
相關(guān)文章
MySQL建立數(shù)據(jù)庫時(shí)字符集與排序規(guī)則的選擇詳解
當(dāng)數(shù)據(jù)庫需要適應(yīng)不同的語言就需要有不同的字符集,下面這篇文章主要給大家介紹了關(guān)于MySQL建立數(shù)據(jù)庫時(shí)字符集與排序規(guī)則的選擇的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-06-06mysql的事務(wù),隔離級別和鎖用法實(shí)例分析
這篇文章主要介紹了mysql的事務(wù),隔離級別和鎖用法,結(jié)合實(shí)例形式分析了MySQL事務(wù),隔離級別和鎖相關(guān)原理、用法及操作注意事項(xiàng),需要的朋友可以參考下2020-02-02