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ù)庫(kù)實(shí)用學(xué)習(xí)資料之常用命令集合
2007-10-12 源自:賽迪網(wǎng) 網(wǎng)友評(píng)論 0 條 進(jìn)入視頻教程
Mysql數(shù)據(jù)庫(kù)是一個(gè)多用戶(hù),多線程的關(guān)系型數(shù)據(jù)庫(kù),是一個(gè)客戶(hù)機(jī)/服務(wù)器結(jié)構(gòu)的應(yīng)用程序。它是對(duì)個(gè)人用戶(hù)和商業(yè)用戶(hù)是免費(fèi)的.
Mysql數(shù)據(jù)庫(kù)具有以下優(yōu)點(diǎn):
1.同時(shí)訪問(wèn)數(shù)據(jù)庫(kù)的用戶(hù)的數(shù)量不受限制
2.可以保存超過(guò)5千萬(wàn)條的記錄
3.是目前市場(chǎng)上現(xiàn)有數(shù)據(jù)庫(kù)產(chǎn)品中運(yùn)行速度最快的數(shù)據(jù)庫(kù)系統(tǒng)
4.用戶(hù)權(quán)限設(shè)置簡(jiǎn)單、有效。
Mysql數(shù)據(jù)庫(kù)常用命令:
啟動(dòng)Mysql數(shù)據(jù)庫(kù)
C:/>cd Mysql5.0/bin
C:/Mysql5.0/bin>mysqld –install 安裝Mysql服務(wù)
C:/Mysql5.0/bin>net start mysql 啟動(dòng)Mysql服務(wù)
請(qǐng)求的服務(wù)已經(jīng)啟動(dòng)。
連接mysql
用戶(hù)需要提供Mysql的用戶(hù)名和密碼來(lái)連接服務(wù)器,如果服務(wù)器不是在本機(jī),則還需要一個(gè)主機(jī)名或IP來(lái)指定服務(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>
使用一條簡(jiǎn)單的查詢(xún)語(yǔ)句
mysql> select version(),current_date;
mysql> select version();select now();
新建或刪除一個(gè)數(shù)據(jù)庫(kù)
Mysql>create database mydb;
Mysql> drop database mydb;
打開(kāi)的數(shù)據(jù)庫(kù)的命令
mysql> use mysql
Database changed
查看數(shù)據(jù)庫(kù)的命令
mysql> show databases;
查看數(shù)據(jù)表的詳細(xì)結(jié)構(gòu)
mysql> desc func;
新建數(shù)據(jù)庫(kù)
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)建新用戶(hù)并給予權(quán)限
mysql> grant all privileges on *.* to dbuser@localhost identified by '1234'
with grant option;
更改Mysql用戶(hù)密碼
c:/Mysql5.0/bin>mysqladmin -u root -p password 1234
Enter password: ****
備份數(shù)據(jù)庫(kù)及表
我們用mysqldump命令來(lái)備份數(shù)據(jù)庫(kù)
c:/mysql/bin/>mysqldump –u root –p 3306 mysql>d:/backup.sql
執(zhí)行此語(yǔ)句將把mydb 備份到D盤(pán)的backup.sql文件中
備份多個(gè)數(shù)據(jù)庫(kù)表
c:/mysql/bin/>mysqldump –u root –p 3306 school user01 user >d:/backup.sql
此句的意思是把school庫(kù)中的user01表和user表的內(nèi)容和表的定義備份到D盤(pán)backup.sql文件中。
備份所有的數(shù)據(jù)庫(kù)
c:/myql/bin>mysqldump –u root –p 3306 –all –database>d:backup.sql
還原Mysql數(shù)據(jù)庫(kù)
c:/mysql/bin/mysql –u root –p 3306 school
還原其中的一個(gè)表
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就可以了.
安裝完畢后,在“開(kāi)始”菜單的“運(yùn)行”中輸入:C:\MySQL\bin\mysqld-nt.exe -install ([color=Red]這個(gè)版本建議安裝在C盤(pán)[/color]),運(yùn)行成功之后再在“開(kāi)始”菜單的“運(yùn)行”輸入:net mysql start ,將會(huì)啟動(dòng) MySQL 服務(wù).
默認(rèn)管理員root 密碼空 請(qǐng)使用PHPMYADMIN 修改.
[color=red]注: 這個(gè)版本建議安裝在C盤(pán),如果安裝后不能啟動(dòng),重啟服務(wù)器后,請(qǐng)直接到系統(tǒng)服務(wù)里面去啟動(dòng)MYSQL.
[/color][color=Blue]怎么刪除mysql服務(wù)?[/color]
開(kāi)始-運(yùn)行-CMD-進(jìn)入MYsql的安裝目錄下的bin目錄輸入下面命令
D:\mysql5\bin>mysqld-nt.exe -remove