本文目錄一覽:
mysql建立的資料庫怎麼使用
mysql創建資料庫命令:1.show databases //顯示資料庫
2.create database student(資料庫名) //創建資料庫student
3.use student //進入student資料庫
4.create table studinfo(表名) (sno int primary key,sage int(2))
………… // 創建表studinfo
5.show table //顯示錶
…………..
6.drop database student //刪除student資料庫
mysql資料庫怎麼導入sql文件
第一步:打在開始界面中找到mysql
第二步:雙擊打開mysql軟體。,並輸入密碼。
第三步:如果sql文件的內容中有創建資料庫的語句或者你想將表存放在你已有的資料庫,在這裡就不用創建資料庫。
第四步:輸入「show databases;」就能看到自己創建的資料庫。
第五步:輸入「use 資料庫名」,開始使用這個資料庫。
第六步:開始導入sql文件,輸入「source sql文件的路徑」(注意你的文件路徑要是複製來的,要將”\”全部換成「/」)
第七步:輸入「show tables」,你就會看到你導入的表了。
如何使用已經安裝的MYSQL資料庫
MYSQL安裝完後,就相當於有了一個DBMS,資料庫管理系統,它本身只是一個後台資料庫而已,單獨安裝資料庫沒有任何意義。
所以,資料庫一般是和前台程序是關聯在一起的,如微軟的幾個開發語言,C++,C#,VB,包括ASP,一般是用來和MS SQL Server打交道的。
而MySQL作為一種開源資料庫管理系統,一般情況下,是和開源的的程序語言打交道的,如Java,PHP等。
每種語言都有一個資料庫介面,這個介面提供了很多函數,用來連接、管理和操縱資料庫,雖然每種語言的這些函數不盡相同,但所進行的操作和原理差別不大。
回到你的問題上,如果你僅僅是想學習MySQL的一些操作的話,那麼你就可以在網上搜MySQL教程了,看看是如何建庫、建表、查詢等操作了。或者是根據mysql手冊也可以。
手冊
教程
mysql資料庫建好後怎麼使用?
1. 添加連接資料庫jar包
2. 稍微修改一下程序
import java.sql.*;
public class ConnectDemoMysql {
private static ConnectDemoMysql instence = null;
private ConnectDemoMysql(){}
public static ConnectDemoMysql getInstence(){
if(instence==null){
instence = new ConnectDemoMysql();
}
return instence;
}
public Connection getConnection(String database){
Connection conn = null;
String mysqldriverName = “com.mysql.jdbc.Driver”;
String mysqlurl = “jdbc:mysql://localhost:3306/”+database;
try {
Class.forName(mysqldriverName);
conn = DriverManager.getConnection(mysqlurl,”root”,”adminadmin”);//mysql密碼
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}
public static void main(String args[]){
Connection conn = ConnectDemoMysql.getInstence().getConnection(“mysqldata”);//輸入你的資料庫名
System.out.println(conn);
}
}
原創文章,作者:KREL,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/145066.html