mysql 終端命令


1、打開數據庫

/usr/local/MySQL/bin/mysql -u root -p

2、輸入root密碼

 

3、使用我的數據庫

use mysql

 

4、查看表

desc table_name

 

5、查看端口號

show global variables like 'port'

 

6、創建表

CREATE TABLE t1(

    id int not null,
    name char(20)
);

CREATE TABLE t1(
    id int not null primary key,
    name char(20)
);

CREATE TABLE t1(
    id int not null,
    name char(20),
    primary key (id,name)
);

CREATE TABLE t1(
    id int not null default 0 primary key,
    name char(20) default '1'
);

 

7、開啟遠程訪問: 
use mysql; 
update user set host = “%” where user = “root”; 
flush privileges;

 

8、關閉遠程訪問: 
use mysql; 
update user set host = “localhost” where user = “root” and host= “%”; 
flush privileges;

 

9、啟動MySQL服務

sudo /usr/local/MySQL/support-files/mysql.server start

10、停止MySQL服務

sudo /usr/local/mysql/support-files/mysql.server stop

11、重啟MySQL服務

sudo /usr/local/mysql/support-files/mysql.server restart


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM