CREATE USER 'dream2008'@'%' IDENTIFIED BY 'dream1234';
GRANT ALL PRIVILEGES ON *.* TO 'dream2008'@'localhost' IDENTIFIED BY 'dream1234'WITH GRANT OPTION
MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
MYSQL數(shù)據(jù)庫實(shí)用學(xué)習(xí)資料之常用命令集合
2007-10-12 源自:賽迪網(wǎng) 網(wǎng)友評論 0 條 進(jìn)入視頻教程
Mysql數(shù)據(jù)庫是一個多用戶,多線程的關(guān)系型數(shù)據(jù)庫,是一個客戶機(jī)/服務(wù)器結(jié)構(gòu)的應(yīng)用程序。它是對個人用戶和商業(yè)用戶是免費(fèi)的.
Mysql數(shù)據(jù)庫具有以下優(yōu)點(diǎn):
1.同時訪問數(shù)據(jù)庫的用戶的數(shù)量不受限制
2.可以保存超過5千萬條的記錄
3.是目前市場上現(xiàn)有數(shù)據(jù)庫產(chǎn)品中運(yùn)行速度最快的數(shù)據(jù)庫系統(tǒng)
4.用戶權(quán)限設(shè)置簡單、有效。
Mysql數(shù)據(jù)庫常用命令:
啟動Mysql數(shù)據(jù)庫
C:/>cd Mysql5.0/bin
C:/Mysql5.0/bin>mysqld –install 安裝Mysql服務(wù)
C:/Mysql5.0/bin>net start mysql 啟動Mysql服務(wù)
請求的服務(wù)已經(jīng)啟動。
連接mysql
用戶需要提供Mysql的用戶名和密碼來連接服務(wù)器,如果服務(wù)器不是在本機(jī),則還需要一個主機(jī)名或IP來指定服務(wù)器的位置。
C:/Mysql5.0/bin>mysql -h localhost -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 6 to server version: 5.0.18-nt
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql>
使用一條簡單的查詢語句
mysql> select version(),current_date;
mysql> select version();select now();
新建或刪除一個數(shù)據(jù)庫
Mysql>create database mydb;
Mysql> drop database mydb;
打開的數(shù)據(jù)庫的命令
mysql> use mysql
Database changed
查看數(shù)據(jù)庫的命令
mysql> show databases;
查看數(shù)據(jù)表的詳細(xì)結(jié)構(gòu)
mysql> desc func;
新建數(shù)據(jù)庫
mysql> create database school;
Query OK, 1 row affected (0.00 sec)
新建表
mysql> create table user01(
-> id varchar(20) NOT NULL,
-> userName varchar(10) NOT NULL,
-> age int(11) default'0',
-> sex char(2) NOT NULL default'm',
-> PRIMARY KEY (id)
-> )TYPE=InnoDB;
Query OK, 0 rows affected, 1 warning (0.02 sec)mysql>desc student;
插入和刪除表中的數(shù)據(jù)
Create table student(stuName varchar(20),age varchar(20),id varchar(20),set0 char(1));
插入
mysql> insert into student(id,stuName) values('1','tomcat');
Query OK, 1 row affected (0.00 sec)
刪除
mysql> delete from student where id='1';
Query OK, 1 row affected (0.01 sec)
刪除表中所有數(shù)據(jù)
mysql> truncate table student;
Query OK, 1 row affected (0.01 sec)
刪除表
mysql> create table temp(t varchar(1));
Query OK, 0 rows affected (0.00 sec)
mysql> drop table temp;
Query OK, 0 rows affected (0.00 sec)
創(chuàng)建新用戶并給予權(quán)限
mysql> grant all privileges on *.* to dbuser@localhost identified by '1234'
with grant option;
更改Mysql用戶密碼
c:/Mysql5.0/bin>mysqladmin -u root -p password 1234
Enter password: ****
備份數(shù)據(jù)庫及表
我們用mysqldump命令來備份數(shù)據(jù)庫
c:/mysql/bin/>mysqldump –u root –p 3306 mysql>d:/backup.sql
執(zhí)行此語句將把mydb 備份到D盤的backup.sql文件中
備份多個數(shù)據(jù)庫表
c:/mysql/bin/>mysqldump –u root –p 3306 school user01 user >d:/backup.sql
此句的意思是把school庫中的user01表和user表的內(nèi)容和表的定義備份到D盤backup.sql文件中。
備份所有的數(shù)據(jù)庫
c:/myql/bin>mysqldump –u root –p 3306 –all –database>d:backup.sql
還原Mysql數(shù)據(jù)庫
c:/mysql/bin/mysql –u root –p 3306 school
還原其中的一個表
mysql> source d:/books.sql;
ERROR:
Unknown command '/b'.
Query OK, 0 rows affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
退出Mysql連接
mysql>quit(exit)
關(guān)閉mysql服務(wù)
C:/mysql/bin>net mysql
(責(zé)任編輯:盧兆林)
mysql4.0.26 win32 下載及安裝方法
[color=blue]mysql4.0.26安裝方法:[/color]
解壓下載后的mysql-4.0.26-win32.rar,執(zhí)行setup.exe,默認(rèn)安裝,一路NEXT就可以了.
安裝完畢后,在“開始”菜單的“運(yùn)行”中輸入:C:\MySQL\bin\mysqld-nt.exe -install ([color=Red]這個版本建議安裝在C盤[/color]),運(yùn)行成功之后再在“開始”菜單的“運(yùn)行”輸入:net mysql start ,將會啟動 MySQL 服務(wù).
默認(rèn)管理員root 密碼空 請使用PHPMYADMIN 修改.
[color=red]注: 這個版本建議安裝在C盤,如果安裝后不能啟動,重啟服務(wù)器后,請直接到系統(tǒng)服務(wù)里面去啟動MYSQL.
[/color][color=Blue]怎么刪除mysql服務(wù)?[/color]
開始-運(yùn)行-CMD-進(jìn)入MYsql的安裝目錄下的bin目錄輸入下面命令
D:\mysql5\bin>mysqld-nt.exe -remove