【转】常用mysql操作命令
Administration 管理
Kill a Thread 结束一个线程
mysql > KILL 999;
Optimize Table 优化表
mysql > OPTIMEZE TABLE foo;
Reload Users Permissions 刷新MySQL系统权限相关表
mysql > FLUSH PRIVILEGES;
Repair Table 修复表
mysql > REPAIR TABLE foo;
Reset the Query Cache 清除查询缓存区中的所有的内容
mysql > RESET QUERY CACHE;
See Which Threads are Running 显示哪些线程正在运行
mysql > SHOW FULL PROCESSLIST;
Backup & Restore
Backup Database to a SQL File 备份数据库
#mysqldump --user admin -- password=password mydatabase > database.sql
Restore Database from SQL File 还原数据库
#mysql < database.sql
Data Definition 数据库描述
Add a Column to a Table
mysql > ALTER TABLE table1 ADD COLUMN newcol TEXT;
Browse Database
mysql > USE dbname;
mysql > SHOW TABLES;
Create Database
mysql > CREATE DATABASE dbname;
Create Table
mysql > CREATE TABLE table (field1 type1, field2 type2, ...)
Drop Database
mysql > DROP DATABASE dbanme;
Remove a Column from a table
mysql > ALTER TABLE table1 DROP COLUMN oldcol;
Rename a Table
mysql > ALTER TABLE table1 RENAME TO newtable2;
Data Manipulation 数据操作
Delete Row from Table
mysql > DELETE from table1 WHERE id = 100;
Insert Row to Table
mysql > INSERT INTO table1(field1, field2, ...) VALUES(value1,value2,...);
Update Row in Table
mysql > UPDATE table1 SET field1 = new_value1 WHERE id = 100;
Emergency Maintenance 常规操作
Find the error log
#tail -f /var/lib/mysqlserver.domain.co.il.err
Recover root Password
Stop MySQL service
#/etc/init.d/mysql stop
Start to MySQL server w/o password
#mysqld_safe --skip-grant-tables &
Connect to mysql
#mysql -u root
Setup new MySQL root user password
mysql > use mysql;
mysql > upda
相关文档:
sudo apt-get install mysql-server mysql-client
sudo apt-get install sun-java6-jdk(安装出意外,sudo dpkg -P sun-java6-bin,然后重新安装)
sudo vi /etc/network/interfaces 配置网络
auto eth0
iface eth0 inet dhcp(static)
address 192.168.8.108
netmask 255.255.255.0
gateway 192.168.8.1
:x保存
sud ......
<?php
$db_name="new";
mysql_connect("localhost","root","123456");
mysql_select_db($db_name);
$tb=mysql_list_tables($db_name);
$sql="";
while($query=mysql_fetch_row($tb)){
$sql="";$table_sql="";
$sql.= get_table_fn($query[0]);
get_table_row($que ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using MySql.Data.MySqlClient;
namespace i_salesDAL
{
public class DBHelper
{
//引导数据库连接数据库调用Web.Config文件
private static MySqlConnection connection;
//创建 ......
aspx页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="customin.aspx.cs" Inherits="kf_customin" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" ......
1、选取最适用的字段属性
MySQL可以很好的支持大数据量的存取,但是一般说来,数据库中的表越小,在它上面执行的查询也就会越快。因此,在创建表的时候,为了获得更好的性能,我们可以将表中字段的宽度设得尽可能小。例如,在定义邮政编码这个字段时,如果将其设置为CHAR(255),显然给数据库增加了不必要的空间,甚至使 ......