標籤:
1.查看MySQL版本資訊:
1,登上 mysql>status;
2,登上 mysql>select version();
3,登上 mysql> select @@version;
4,不登 [[email protected] ~]# mysql -V
5,不登 [[email protected] ~]# mysql --help | grep Distrib ;
2.MySQL服務啟動:
1,window下啟動服務 net start mysql
2,window下停止服務 net stop mysql
3,linux下啟動服務 service mysql start
4,linux下停止服務 service mysql stop
3.當系統上啟動多個連接埠的MySQL的時候:
1,串連的方式:mysql -uroot [email protected] -P 3306-S /mysqldata/database/data3306/mysql1.sock
2,當出現連結不上的問題執行下面的命令:
a)mysql>grant all privileges on *.* to [email protected]"%" identified by "password" with grant option;
b)mysql>flush privileges;
4.MySQL的一些常用的查看命令:
1,查看資料庫 mysql>show databases;
2,選擇資料庫 mysql>use databasesname;
3,查看資料庫中存在的函數 mysql> show function status;
4,查看視圖 mysql>select * from information_schema.VIEWS;
5,查看錶 mysql>show tables;
6,查看觸發器 mysql>show triggers;
7,查看目前使用者 mysql> select user();
8,查看所有使用者 mysql>select user,host,password from mysql.user;
9,查看MySQL字元集 mysql>show variables like ‘%char%‘;
10,查看資料庫的字元集 mysql>show create database databasename;
11,查看錶的字元集 mysql>show create table databasename.tablename \G;
12,查看當前選擇的資料 mysql>select database();
5.MySQL對錶和資料的一些操作命令:
1, 將文字檔的資料裝載到表中:mysql>Load data local infile "mytable.txt" into table mytable;
2,給欄位增加 primary key : mysql> alter table tablename add primary key(id);
3,刪除primary key: mysql>alter table tablename drop primary key; 或者 mysql>drop primary key on tablename;
4,添加新欄位 :mysql>alter table tablename add column columnname char(1);或者 mysql>alter table tablename add field int(11) nosiged not null;
5,刪除欄位: mysql>alter table tablename drop column c;
6,在列d上增加一個索引,並且使列a為主鍵: mysql>alter table tablename index(d),add primary key(a);
7,增加一個新的AUTO_INCREMENT整數列,命名為c : mysql>alter table tablename add c int unsigned not null auto_increment ,add index(c);
6.MySQL操作出現問題的解決辦法:
1,出現function不能建立:
mysql>show variables like ‘log_bin_trust_function_creators‘;
mysql>set global log_bin_trust_function_creators=1;
MySQL常用技巧