sudo ufw allow 3306/tcp
sudo service ufw restart
bind-address 127.0.0.1
sudo /etc/init.d/mysql restart
Computer has revolutionized the world and programming is the most important tool to make our dream come true;
sudo ufw allow 3306/tcp
sudo service ufw restart
bind-address 127.0.0.1
sudo /etc/init.d/mysql restart
";
}
mysql_close($conn);
//以下是php内嵌html代码
$ar = array('demo' => '111', 'test' => '222');
$html = <<
HTML;
echo $html;
CREATE USER 'hr'@'localhost' IDENTIFIED BY '1234';
GRANT ALL PRIVILEGES ON company.* TO 'hr'@'localhost';
CREATE TABLE user_table(
id INT NOT NULL AUTO_INCREMENT,
user VARCHAR(20) NOT NULL,
password VARCHAR(30) NOT NULL,
PRIMARY KEY (id )
);
insert into user_table (user, password) values("guest","123456");
alter table location add my_point point;// location with 经纬坐标
update location SET my_point = PointFromText(CONCAT('POINT(',long,' ',latt,')'));
将会自动计算,以blob形式存储
import java.sql.*;
public class DBTest {
static Connection conn = null;
public static void main(String[] args) {
// Initialize variables for fields by data type
String ssn;
String firstName;
String lastName;
String address;
int dno;
int linect = 0;
try {
// Create a connection to the local MySQL server, with the "company" database selected.
// conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/company", "root", "mypassword");
// Create a connection to the local MySQL server, with the NO database selected.
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/", "root", "");
// Create a SQL statement object and execute the query.
Statement stmt = conn.createStatement();
// Set the current database, if not already set in the getConnection
// Execute a SQL statement
// String chooseDatabase = "use company;"
stmt.execute("use company;");
// Execute a SQL query using SQL as a String object
ResultSet rs = stmt.executeQuery("SELECT ssn, fname, lname, dno FROM employee;");
// Iterate through the result set using ResultSet class's next() method
while (rs.next()) {
// Keep track of the line/tuple count
linect++;
// Populate field variables
firstName = rs.getString("fname");
lastName = rs.getString("lname");
// dno = rs.getInt("dno");
ssn = rs.getString("ssn");
dno = Integer.parseInt(rs.getString("dno"));
// Do something with the data
System.out.print(linect + ".\t");
System.out.print(ssn + "\t");
System.out.print(firstName + "\t");
System.out.print(lastName + "\t");
System.out.print(dno + "\t");
System.out.println();
} // End while(rs.next())
// Always close the recordset and connection.
rs.close();
conn.close();
System.out.println("Success!!");
}
catch(SQLException ex) {
System.out.println("Error in connection: " + ex.getMessage());
}
}
}
}
| ID | 书名 | 出版社 | 价格 |
| 1001 | An inconvenient truth | Bogdonoff & Rubin | 45.0 |
| 1002 | The satanic gases | Rodale | 49.0 |
| 1003 | Global climate change and wildlife | Cato Institute | 59.0 |
| 1004 | Environmental resource handbook | Wildlife Society | 59.0 |
| 1005 | American heritage science dictionary | Houghton Mifflin Book | 56.0 |