linux下mysql經常使用的命令

linux下搭建完mysql後,一些經常使用的數據庫命令: mysql

建立庫:create database mydatabase;
顯示全部數據庫列表:show databases;
刪除數據庫:drop dabatase mydatabase;
制定mydatabase爲當前默認數據庫:use mydatabase;
建立表:create table custmoers(userid int not null,username varchar(20)not null);
刪除表:drop table cutomers;
顯示錶:show tables;
顯示錶結構:desc customers;
向customers表中插入一條記錄:insert into customers(userid,username) values(1,'hujiahui');
讓操做即時生效:commit;
查詢customers中的記錄:select * from customers;
更新表中的數據:update customers set username='licongying' where userid=1;
刪除表中的記錄:delete from customers;
授予hjh用戶訪問數據庫的權限:grant select,insert,update,delete on *.* to hjh@localhost identified by"123456",其中hjh是用戶名
          123456是密碼
登陸mysql:mysql -uhjh -p123456
linux

更改mysql裏user的密碼:【以root爲例】 sql

mysql -uroot -p 數據庫

Enter password: 【輸入原來的密碼】
mysql>use mysql;
mysql> update user set password=passworD("test") where user='root';
mysql> flush privileges;

ide

                                                                                             新浪微博@皮子喜歡打籃球







ui

相關文章
相關標籤/搜索