MySQLѧϰ
×öÈí¼þÊý¾Ý¿â±Ø²»¿ÉÉÙ£¬ÎÒÑ¡ÔñÁËMySQL¡£
Ê×Ïȵ½http://dev.mysql.com/downloads/ÏÂÔغÃMySQL5.1ºÍMySQL GUI TOOLS
ϵ½µçÄÔÉÏ,È»ºó°²×°£¬ÏÈ×°5.1ÔÙ×°gui tools ,һ·ȷ¶¨°É¡£
ŪºÃºó£¬µã¿ªMySQL Query Browser£¬¾Í¿ÉÒÔ²Ù×÷Êý¾Ý¿âÁË¡£
MySQLµÄÇý¶¯³ÌÐòÊÇGUITOOLS°²×°Ä¿Â¼/java/libϵÄmysql-connector-java-5.0.4-bin.jar
°ÑËü·Åµ½ */tomcat6.0/lib ÏÂÃ棬ÔÙ°ÑÕâÌõ·¾¶¼ÓÈëµ½classpathÀï±ß£¬ÔÚjspÖоͿÉÒÔÓÃÁË¡£
ÔÚ.java³ÌÐòÖУ¬ÒªÅäÖúù¹½¨Â·¾¶£¬·½·¨£ºÅäÖù¹½¨Â·¾¶->¿â->Ìí¼ÓÍⲿjar->Ñ¡ÔñÊý¾Ý¿âÇý¶¯ ¾ÍOKÀ²¡£
ÏÂÃæÊÇÒ»¸öµäÐ͵ÄʹÓÃÊý¾Ý¿âµÄÀý×Ó£º£¨ÔÚʹÓÃÇ°£¬Òª½¨ºÃÊý¾ÝÔ´ºÍ±íŶ£©
package mypackage;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
public class ConToDBTest {
public static void main(String[] args) {
String user="root"; //̞
String pass="root"; //ÃÜÂë
String dbName="test"; //Êý¾ÝÔ´Ãû
String tableName="student"; //±íÃû
String driver="com.mysql.jdbc.Driver"; //Êý¾Ý¿âÇý¶¯³ÌÐò
String url="jdbc:mysql://localhost:3306/"+dbName;//Áª½á·¾¶
String sqlStr; //SQLÓï¾ä
Connection con=null; //Á¬½Ó¶ÔÏó
Statement stmt=null; //Óï¾äÈÝÆ÷
ResultSet rs=null; //½á¹û¼¯
try{
Class.forName(driver); //¼ÓÔØÇý¶¯
con=DriverManager.getConnection(url,user,pass); //Á¬½ÓÊý¾Ý¿â
stmt=con.createStatement(); //´´½¨ÈÝÆ÷
//ÔÚ±ístudentÖвåÈë¼Ç¼
sqlStr="insert into "+tableName+" values('000099988','zhangli',21)";
stmt.executeUpdate(sqlStr);
//²éÕÒ±ístudentÖеļǼ
sqlStr="select * from "+tableName;
rs=stmt.executeQuery(sqlStr);
ResultSetMetaData rsmd=rs.getMetaData();//»ñÈ¡ÔªÊý¾Ý
//ÏÔʾÊôÐÔÃû
int j=0;
j=rsmd.getColumnCount();
for(int k=0;k<j;k++){
System.out.print(rsmd.getColumnName(k+1));
System.out.print("\t");
}
System.out.print("\n");
//ÏÔʾ¼Ç¼
while(rs.next()){
for(int i=0;i<j;i++){
System.out.print(rs.getString(i+1));
Sys
Ïà¹ØÎĵµ£º
Ò»Ö±ÒÔΪmysqlËæ»ú²éѯ¼¸ÌõÊý¾Ý£¬¾ÍÓÃ
SELECT * from `table` ORDER BY RAND() LIMIT 5
¾Í¿ÉÒÔÁË¡£
µ«ÊÇÕæÕý²âÊÔһϲŷ¢ÏÖÕâÑùЧÂʷdz£µÍ¡£Ò»¸ö15ÍòÓàÌõµÄ¿â£¬²éѯ5ÌõÊý¾Ý£¬¾ÓȻҪ8ÃëÒÔÉÏ
²é¿´¹Ù·½ÊֲᣬҲ˵rand()·ÅÔÚORDER BY ×Ó¾äÖлᱻִÐжà´Î£¬×ÔȻЧÂʼ°ºÜµÍ¡£
You cannot use a column with RAND() values i ......
½ñÌ죬ҪÓÃexplain²é¿´mysqlµÄÖ´Ðй滮£¬µ«ÊǺÍPostgreSQL²»Í¬µÄÊÇ£¬Ö±½ÓÔÚmysqlÀïÃæÖ´ÐеĽá¹û¿É¶ÁÐÔ²»ÊǺܺã¬ÉÏÍøËÑÁËһȦ£¬·¢ÏÖÁËÒ»¸ö¹¤¾ßmaatkit£¬¿ÉÒÔ½²explainµÄ½á¹ûת»¯ÎªÊ÷×´½á¹¹²é¿´£¬ºÇºÇ£¬·½±ãÁ˺ܶà
°²×°°ì·¨£º
1. sudo yum install mysql
2. sudo yum install mysql-server
3. wget http://maatkit.googl ......
1¡¢µÇ½MySQL:
mysql -u root -p
2¡¢²é¿´Óû§ÐÅÏ¢
select user,host,password from mysql.user;
select user,host from mysql.user;
3¡¢ÉèÖÃÃÜÂë
set password for root@localhost=password('
ÔÚÕâÀïÌîÈërootÃÜÂë
');
4¡¢ÐÞ¸ÄÃÜÂë
·½·¨1£ºmysqladmin -u root -p password newpassword
·½·¨2£º ££mysql -u root ......
MySQLÖг£ÓõÄÐ޸ıíµÄÃüÁî
¹Ø¼ü×Ö: mysql, Ð޸ıí, ÃüÁî
ÔÚÊý¾Ý¿â²Ù×÷ÖÐ,¸öÈ˾õµÃʹÓõÃ×î¶àµÄ¾ÍÊDzéѯ,È»ºó¾ÍÊǶԱíµÄÐ޸IJÙ×÷ÁË,ÓÈÆäÊǵ±Êý¾Ý¿âµÄÉè¼Æ¹¤×÷ûÓÐ×öºÃʱ.ÏÂÃæ¾ÍMySQLÖÐһЩ³£ÓõÄÐ޸ıíµÄ²Ù×÷½øÐÐ×ܽá:
ΪÁË·½±ãºóÃæµÄ˵Ã÷,ÏÈ´´½¨Ò»¸ö±í,´´½¨Óï¾äÈçÏÂ:
Create ......