随笔-62  评论-29  文章-0  trackbacks-0

1,先看看系统中是否自带其它版本的MySQL,命令如下:
#rpm -qa|grep MySQL

#rpm -qa|grep mysql
如果带有此软件,请先用rpm -e将这些软件干掉,命令如下:
#rpm -e mysql*****(此处为你的包名,即上面查询出来的名字)
如果在删除的过程中提示因为一些依赖关系无法删除,请用如下命令:
#rpm -e --nodeps mysql*****

2,去MySQL的官方网站上下载RPM包,根据你的服务器的CPU型号和Redhat版本选择不同的RPM包(包括服务端和客户端的包),地址如下:
http://dev.mysql.com/downloads/mysql/5.0.html

3,在Redhat中新增用户和用户组,命令如下:
#groupadd mysql
#useradd -g mysql mysql

4,将下载的放到Redhat的某一目录下,分别执行命令安装服务端和客户端的RPM包,命令如下:
#rpm -ivh MySQL-server-community-5.0.67-0.rhel4.i386.rpm
#rpm -ivh MySQL-client-community-5.0.67-0.rhel4.i386.rpm

5,修改root用户的密码:
# killall mysqld
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit

6,修改root用户远程访问的权限:
# killall mysqld
# mysqld_safe --user=mysql &
# mysql -u root -p mysql
Enter password: (输入第5步中修改后的新密码)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> quit

 

如果以上步骤不行

{

5,修改root用户远程访问的权限:

# killall mysqld

# mysqld_safe --user=mysql &

# mysql -u root -p mysql

Enter password: (输入第5步中修改后的新密码)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;

mysql> FLUSH PRIVILEGES;

mysql> quit

mysql> delete from user where host<>'%';

 

6,修改root用户的密码:(密码丢失的时候可以用这种发式修改密码)

# killall mysqld

# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

# mysql -u root mysql

mysql> UPDATE user SET Password=PASSWORD('orient5757') where USER='root';

mysql> FLUSH PRIVILEGES;

mysql> quit

 

7,重新启动

killall mysqld

service mysql start

 

}



7:相关使用

backup
C:\Documents and Settings\Administrator>mysqldump -u root -h localhost -p123456  pink>c:\c.sql

//-p123456不空格就不提示输入密码
C:\Documents and Settings\Administrator>mysqldump -u root -h localhost -porient5757  pink>/work/pink.sql


restore
C:\Documents and Settings\Administrator>mysql -u root -p123456 -h localhost pink</work/c.sql

//-p123456不空格就不提示输入密码
C:\Documents and Settings\Administrator>mysql -u root -p123456 -h localhost dump<c:\c.sql

修改密码
UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
FLUSH PRIVILEGES;

授权
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;

登陆

mysql -u root -h localhost -porient5757

show databases;
use mysql;
show tables;
desc user;



posted on 2008-10-06 14:46 阅读(213) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: