Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JavaÁ¬½ÓmysqlÊý¾Ý¿â

Ê×ÏÈ£¬´ò¿ªMySQL Query Browser£¬ÔÚµ±Ç°TestÊý¾Ý¿âÏ£¬Ð½¨Ò»¸östudent±í£¬ÓÐÈçÏÂÊôÐÔ£º
create table student (name varchar(10),id int(2),sex varchar(10));
 
³ÌÐò¼ûÏ£º
package com.JDBC;
import java.sql.*;
public class JDBCTest {
public static void main(String[] args) {String driver = "com.mysql.jdbc.Driver"; // Çý¶¯³ÌÐòÃû
String url = "jdbc:mysql://localhost/test"; // URLÖ¸ÏòÒª·ÃÎʵÄÊý¾Ý¿âÃûscutcs
String user = "root"; // MySQLÅäÖÃʱµÄÓû§Ãû
String password = "123456"; // MySQLÅäÖÃʱµÄÃÜÂë
try {
Class.forName(driver); // ¼ÓÔØÇý¶¯³ÌÐò
Connection conn = DriverManager.getConnection(url, user, password); // Á¬ÐøÊý¾Ý¿â
if (!conn.isClosed())
System.out.println("Succeeded connecting to the Database!"); // ÑéÖ¤ÊÇ·ñÁ¬½Ó³É¹¦
Statement statement = conn.createStatement(); // statementÓÃÀ´Ö´ÐÐSQLÓï¾ä
String sql = "select * from student"; // ÒªÖ´ÐеÄSQLÓï¾ä
ResultSet rs = statement.executeQuery(sql); // ½á¹û¼¯
System.out.println("-----------------------------------------");
System.out.println("Ö´Ðнá¹ûÈçÏÂËùʾ:");
System.out.println("-----------------------------------------");
System.out.println(" ѧºÅ" + "\t\t" + " ÐÕÃû" + "\t\t" + "ÐÔ±ð");
System.out.println("-----------------------------------------");
String name = null;
while (rs.next()) {
name = rs.getString("name"); // Ñ¡ÔñnoÕâÁÐÊý¾Ý
System.out.println(rs.getString("id") + "\t\t" + name + "\t\t"
 + rs.getString("sex")); // Êä³ö½á¹û
}
rs.close();
conn.close();
} catch (ClassNotFoundException e) {
System.out.println("Sorry,can`t find the Driver!");
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}


Ïà¹ØÎĵµ£º

ÉèÖÃmysqlĬÈϱàÂë

°²×°ºó
/etc/init.d/mysql start (stop) ΪÆô¶¯ºÍÍ£Ö¹·þÎñÆ÷
/etc/mysql/ Ö÷ÒªÅäÖÃÎļþËùÔÚλÖà my.cnf
/var/lib/mysql/ ·ÅÖõÄÊÇÊý¾Ý¿â±íÎļþ¼Ð£¬ÕâÀïµÄmysqlÏ൱ÓÚwindowsÏÂmysqlµÄdateÎļþ¼Ð
Æô¶¯mysqlºó£¬ÒÔrootµÇ¼mysql
isher@isher-ubuntu:~$ mysql -u root
>show variables like 'character%'; #Ö´ÐбàÂëÏ ......

MySQL 5.1ÍêȫжÔØ

ÓÉÓÚ°²×°MySQLµÄʱºò£¬ÊèºöûÓÐÑ¡Ôñµ×²ã±àÂ뷽ʽ£¬²ÉÓÃĬÈϵÄASCIIµÄ±àÂë¸ñʽ£¬ÓÚÊǽӶþÁ¬ÈýµÄÖÐÎÄת»»ÎÊÌâËæÖ®¶øÀ´£¬¾ÍÏëжÔØÁËÖØа²×°MYSQL£¬ÕâһжÔص¹ÊdzöÁËÎÊÌ⣬µ¼Ö°²×°µÄʱºò°²×°²»ÉÏ£¬ÔÚÍøÉÏÕÒÁËÒ»¸ö¶àСʱҲû½â¾ö¡£
ÖØװϵͳÓÀÔ¶ÊǸöºÃ°ì·¨£¬µ«ÓÐ˭ϲ»¶Õâô×öѽ:(
ºóÀ´ÎÞÒâ·¢ÏÖÊÇжÔصÄʱºòûÓÐжÔØÍêÈ«µ¼Ö£ ......

MySQL³£ÓõÄһЩÓÐЧÃüÁîÂÞÁÐ

¼ò¼òµ¥µ¥µÄÂÞÁÐһЩÈÕ³£³£ÓõÄMySQLÃüÁî¡£
show variables;
²é¿´Êý¾Ý¿âÅäÖõÄһЩÅäÖÃÏî
show status;
²é¿´µ±Ç°Æô¶¯µÄMySQL״̬
select @@autocommit;
²é¿´MySQLµ±Ç°Ö´ÐÐSQLµÄÌá½»ÀàÐÍ£¨ÊÇ·ñ×Ô¶¯Ìá½»£©
\s
µ±Ç°Á¬½ÓÊý¾Ý¿âÃû£¬Óû§Ãû£¬MySQL°æ±¾£¬×Ö·û¼¯µÈµÈ¡£
show create table table_name \G
²é¿´´´½¨±íµÄSQLÓï ......

mysqlÊý¾ÝÂÒÂëÎÊÌâÔ­Òò¼°½â¾ö£¨×ܽáƪ£©

 mysqlÊý¾ÝÂÒÂëÎÊÌâÔ­Òò¼°½â¾ö£¨×ܽáƪ£©
 
µÚÒ»½â¾ö·½·¨£º
 
      ÂÒÂëÎÊÌâ¼òµ¥Ëµ¾ÍÊÇÊý¾Ý¿âдÈë¶ÁÈ¡£¬ÍøÒ³Îļþ£¬ÍøÒ³ÏÔʾʱ¼¸¸ö»·½ÚµÄ±àÂë²»Ò»ÖÂÔì³ÉµÄ¡£
ÂÒÂëÎÊÌâ
дÈëʱ£ºÒ³ÃæÌáȡдÈëÊý¾Ý±àÂëºÍдÈëÊý¾Ý¿âʱ±àÂë²»Ò»ÖÂ
¶Áȡʱ£º¶ÁÈ¡ºóËùÓñàÂëÓëÊý¾Ý¿âдÈëʱ²»Ò»ÖÂ
......

MySQL Reference ManualÖÐÎÄ°æ

MySQL Reference Manual for version 4.1.0-alpha.
¡¡ÒëÕßÐò
¡¡ÁÐÀàÐÍÓ뺯ÊýË÷Òý
6 MySQL ÓïÑԲο¼

6.1 ÓïÑԽṹ

6.1.1 ÎÄ×Ö£ºÔõôд×Ö·û´®ÓëÊý×Ö

6.1.1.1 ×Ö·û´®

 
6.1.1.2 Êý×Ö

 
6.1.1.3 Ê®Áù½øÖÆÖµ
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ