《MySQL安装和使用》PPT课件.ppt
MySQL安装和使用解航TS Team 2007-01-27优缺点n n优点:成本低、易用、速度快n n缺点:功能较弱、支持数据量较小(一个表中的数据量超过1000万条就比较慢了)安装 MySQLn n安装StandardSystem时选择Mysql并安装n n重要参数如下:数据:数据库存放在/var/db/mainError log:在/var/db/main/mysql.errSocket file:/var/db/main/mysql.sockMy_cnf:/var/db/main/fMySQL的使用(一)n n启动/usr/local/app/mysql-main startn n关闭/usr/local/app/mysql-main stopn n重启 /usr/local/app/mysql-main restartn n察看状态 /usr/local/app/mysql-main statMySQL的使用(二)n n本机使用MySQLcd/usr/local/mysql/bincd/usr/local/mysql/bin./mysql-u root./mysql-u root-S/var/db/main/mysql.sock-pS/var/db/main/mysql.sock-p FtxxxxFtxxxxn n远程使用MySQL,客户端工具MySQL Administrator MySQL Query Browser phpMyAdminMySQL的使用(三)n n用户操作添加用户:添加用户:Mysql GRANT ALL ON test.*TO rootlocalhostMysql GRANT ALL ON test.*TO rootlocalhost IDENTIFIED BY goodsecret;IDENTIFIED BY goodsecret;删除用户权限:删除用户权限:Mysql Mysql revoke all on*.*from rootlocalhost;revoke all on*.*from rootlocalhost;MySQL的使用(四)n n配置f exampleMySQL的使用(五)n n日志文件日志文件 The error log The error log Logs problems encountered starting,running,or stopping Logs problems encountered starting,running,or stopping mysqldmysqld.n nThe query logThe query logLogs established client connections and executed statements.Logs established client connections and executed statements.n nThe update logThe update logLogs statements that change data.This log is deprecated.Logs statements that change data.This log is deprecated.n nThe binary log The binary log Logs all statements that change data.Also used for replication.Logs all statements that change data.Also used for replication.n nThe slow logThe slow logLogs all queries that took more than long_query_time seconds to Logs all queries that took more than long_query_time seconds to execute or didnt use indexes.execute or didnt use indexes.MySQL的使用(六)n nApacheApache:DBIDBI在使用了在使用了mod_perlmod_perl的的web serverweb server上,应该使用上,应该使用ApacheApache:DBIDBI模块,维持一些模块,维持一些dbdb连接,防止连接,防止mysqlmysql出现出现 too many connectionstoo many connections 的情况。的情况。安装好安装好ApacheApache:DBIDBI之后,只需要在之后,只需要在apacheapache的的confconf文件中加一句文件中加一句 PerlModule PerlModule ApacheApache:DBIDBI 然后重启然后重启apacheapache,就可以了,不需要改动任何,就可以了,不需要改动任何程序。程序。MySQL的使用(七)n n备份备份mysqldumpmysqldumpn nshell shell mysqldump-opt mysqldump-opt db_namedb_name xxx.sql xxx.sql/usr/local/mysql/bin/mysqldump-socket=/var/db/main/mysql.sock-user=root/usr/local/mysql/bin/mysqldump-socket=/var/db/main/mysql.sock-user=root-password=Ft*-lock-tables=false-databases mydb-password=Ft*-lock-tables=false-databases mydbn n导入数据的方法导入数据的方法shell mysql database_name mysql database_name cat*sql|mysql database_nameshell cat*sql|mysql database_name解航msn:就到这里