日期:2014-05-16 浏览次数:20689 次
[root@MT src]# rpm -ivh MySQL-server-community-5.0.41-0.rhel4.i386.rpm
warning: MySQL-server-community-5.0.41-0.rhel4.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing...??????????????? ########################################### [100%]
?? 1:MySQL-server-community ########################################### [100%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h MT password 'new-password'
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
Starting MySQL.......... SUCCESS!
如碰到安装失败(如perl(DBI)),只要安装相应的软件即可!
同理,安装 MySQL-client-4.0.16-0.i386.rpm
[root@MT src]# rpm -ivh MySQL-client-4.0.16-0.i386.rpm
2.修改MySQL密码
[root@MT src]# mysqladmin -u root password mysql
3.MySQL数据库管理
(1)关闭与启动
[root@MT src]# mysqladmin -u root -p shutdown
[root@MT src]# /et/init.d/mysql start
(2)更换MySQL目录
[root@MT src]# mysqladmin -u root -p shutdown
[root@MT src]# cp /var/lib/mysql /home/mysql/5.0/
[root@MT src]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
[root@MT src]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
[root@MT src]# vi /etc/my.cnf
# The following options will be passed to all MySQL clients
[client]
#password?????? = your_password
port??????????? = 3306
##Modified content MartriWang@gmail.com
#socket???????? = /var/lib/mysql/mysql.sock
socket????????? = /home/mysql/5.0/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port??????????? = 3306
#socket???????? = /var/lib/mysql/mysql.sock
##Modified content MartriWang@gmail.com
socket????????? = /home/mysql/5.0/mysql/mysql.sock
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
[root@MT src]# vi /etc/init.d/mysql
# The following variables are only set for letting mysql.server find things.
# Set some defaults
pid_file=
server_pid_file=
use_mysqld_safe=1
user=mysql
if test -z "$basedir"
then
? basedir=/
? bindir=/usr/bin
? if test -z "$datadir"
? then
##Modified content MartriWang@gmail.com
#??? datadir=/var/lib/mysql
???? datadir=/home/mysql/5.0/mysql
[root@MT src]#/etc/init.d/mysql start
(3)MySQL目录
数据库目录:/var/lib/mysql/(可更改,前面已经介绍)
配置文件:/usr/share/mysql(mysql.server命令及配置文件)
相关命令:/usr/bin(mysqladmin mysqldump等命令)
启动脚本:/etc/rc.d/init.d/(ln -s /etc/init.d/)(启动脚本文件mysql的目录)
(4)备份与恢复
备份:[root@MT src]#mysqldump -u root -p --opt mysql > mysql_back
恢复:[root@MT src]#mysql -u root -p mysql < mysql_back