三. mysql server安装
------------------以下为扩展:删除mysql----------------
删除 mysql
sudo apt-get autoremove --purge mysql-server-5.0
sudo apt-get remove mysql-server
sudo apt-get autoremove mysql-server
sudo apt-get remove mysql-common //这个很重要 应该为自动删除autoremove
上面的其实有一些是多余的。
清理残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
--------------------扩展完毕--------------------------
1. mysql server安装
1.sudo apt-get install mysql-server mysql-client
2.输入root密码为root
3.更改mysql最大连接数:
sudo gedit /etc/mysql/my.cnf 增加或修改max_connections=1024;
2.进入mysql:
sudo mysql –u root -p 输入密码root进入。
3.添加/删除权限
&nbs ......
要備份 MySQL 資料庫主要分為兩個方法,一是將資料庫目錄完整備份:二是使用 MySQL 內建的 mysqldump 程式。
備份資料庫目錄
MySQL 預設的儲存目錄在 /var/lib/mysql 內容,底下會有以資料庫名稱的目錄,例如 mydb
目錄便應該是 mydb 資料庫的資料。
如果 MySQL 正在運行,請先停止 MySQL,原因是可能會有資料未完全寫入,而 MySQL 會 lock 在使用中的 DB 檔案。
01
/etc/rc.d/init.d/mysqld stop
02
cd /var/lib/mysql/
03
tar zxcf mydb_backup.tgz mydb
04
/etc/rc.d/init.d/mysqld start
以上指令會先停止 MySQL,然後把 mydb 資料庫製作一個 taz 檔的備份,並儲存到 mydb_backup.tgz。
在使用以上指令時,請根據個別系統的設定作出修改。
好了,以上就麼 3 ......
MySQL Cluster
is a technology that enables
clustering of in-memory databases in a shared-nothing system. The
shared-nothing architecture allows the system to work with very
inexpensive hardware, and with a minimum of specific requirements
for hardware or software.
MySQL Cluster is designed not to have any single point of failure.
In a shared-nothing system, each component is expected to have its
own memory and disk, and the use of shared storage mechanisms such
as network shares, network file systems, and SANs is not recommended
or supported.
MySQL Cluster integrates the standard MySQL server with an in-memory
clustered storage engine called NDB
(which stands for “N
etwork
D
ataB
ase
”). In our
documentation, the term NDB
refers to
the part of the setup that is specific to the storage engine,
whereas “MySQL Cluster
” refers to the combination of
one or mor ......
NDBCLUSTER
(also known as NDB
) is an in-memory
storage engine offering high-availability and data-persistence
features.
The NDBCLUSTER
storage engine can be
configured with a range of failover and load-balancing options,
but it is easiest to start with the storage engine at the cluster
level. MySQL Cluster's NDB
storage
engine contains a complete set of data, dependent only on other
data within the cluster itself.
The “Cluster
” portion of MySQL Cluster is configured
independently of the MySQL servers. In a MySQL Cluster, each part
of the cluster is considered to be a node
.
Note
In many contexts, the term “node
” is used to
indicate a computer, but when discussing MySQL Cluster it means
a process
. It is possible to run multiple
nodes on a single computer; for a computer on which one or more
cluste ......
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保存
sudo ifconfig eth0 down (up)关闭和启动
sudo /etc/init.d/networking restart
-----------------------------------
远程授权访问msyql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.8.108' IDENTIFIED BY '' WITH GRANT OPTION ;
etc/mysql/my.cnf注释掉 bind 127.0.0.1
重新启动mysql :sudo /etc/init.d/mysql restart
--------------------------------------------- ......
<?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($query[0]);
// echo $table_sql."\n";
}
$f=fopen($db_name.".sql","w+");
fwrite($f,$sql);
fclose($f);
//备份所有表SQL语名
function get_table_fn($db_name){
$field="CREATE TABLE `$db_name`( \n";
$query=mysql_query("select * from $db_name");
while($row=mysql_fetch_field($query)){
if($row->not_null===1){$null="DEFAULE NULL";}else{$null="NOT NULL";}
if($row->primary_key===1){$key="primary key";}else{$key="";}
if($row->unsigned===1){$unsig="unsigned";}else{$unsig="";}
$field.="`$row->name` $row->type($row->max_length) $null $key $unsig ,\n";
}
$field.=")\n";
return $fi ......