linux mysql 5.1 卸载_Linux环境下卸载、安装及配置MySQL5.1

Linux环境下卸载原有MySQL5.1数据库,并重新安装MySQL数据库的示例记录。

一、卸载MySQL

查看主机中是否安装了MySQL数据库:

[root@RD-viPORTAL-1 ~]# rpm -qa|grepmysql

mysql-5.1.73-5.el6_6.x86_64

mysql-devel-5.1.73-5.el6_6.x86_64

mysql-libs-5.1.73-5.el6_6.x86_64

然后通过rpm -e命令进行软件包的卸载;

[root@RD-viPORTAL-1 ~]# rpm -e mysql-5.1.73-5.el6_6.x86_64

error: Failed dependencies:

mysql= 5.1.73-5.el6_6 is needed by (installed) mysql-devel-5.1.73-5.el6_6.x86_64

发现软件包有依赖关系,百度发现可以使用“--nodeps”参数进行卸载。

[root@RD-viPORTAL-1 ~]# rpm -e mysql-5.1.73-5.el6_6.x86_64 --nodeps

[root@RD-viPORTAL-1 ~]# rpm -e mysql-devel-5.1.73-5.el6_6.x86_64 --nodeps

[root@RD-viPORTAL-1 ~]# rpm -e mysql-libs-5.1.73-5.el6_6.x86_64 --nodeps

再次查询MySQL的软件包,发现已经没有相关的rpm包了。

[root@RD-viPORTAL-1 ~]# rpm -qa|grepmysql

[root@RD-viPORTAL-1 ~]#

二、安装MySQL

安装MySQL一般需要如下rpm包。

[root@RD-viPORTAL-1mysql]# ll

总用量11788

-rw-r--r-- 1 root root 915088 2月 15 05:27 mysql-5.1.73-5.el6_6.x86_64.rpm-rw-r--r-- 1 root root 131900 2月 15 05:27 mysql-devel-5.1.73-5.el6_6.x86_64.rpm-rw-r--r-- 1 root root 1282760 2月 15 05:27 mysql-libs-5.1.73-5.el6_6.x86_64.rpm-rw-r--r-- 1 root root 9033560 2月 15 05:27 mysql-server-5.1.73-5.el6_6.x86_64.rpm-rw-r--r-- 1 root root 136464 2月 15 05:32 perl-DBD-MySQL-4.013-3.el6.x86_64.rpm

安装顺序:

perl-DBD-MySQL-4.013-3.el6.x86_64.rpm

mysql-libs-5.1.73-5.el6_6.x86_64.rpm

mysql-5.1.73-5.el6_6.x86_64.rpm

mysql-server-5.1.73-5.el6_6.x86_64.rpm

mysql-devel-5.1.73-5.el6_6.x86_64.rpm

安装过程:

使用“rpm -ivh”命令安装rpm包。

[root@RD-viPORTAL-1 mysql]# rpm -ivh mysql-libs-5.1.73-5.el6_6.x86_64.rpm

Preparing...                ########################################### [100%]

1:mysql-libs             ########################################### [100%][root@RD-viPORTAL-1 mysql]# rpm -ivh mysql-5.1.73-5.el6_6.x86_64.rpm

Preparing... ########################################### [100%]1:mysql ########################################### [100%]

[root@RD-viPORTAL-1mysql]#

[root@RD-viPORTAL-1 mysql]# rpm -ivh mysql-server-5.1.73-5.el6_6.x86_64.rpm

Preparing... ########################################### [100%]1:mysql-server ########################################### [100%]

[root@RD-viPORTAL-1mysql]#

[root@RD-viPORTAL-1 mysql]# rpm -ivh mysql-devel-5.1.73-5.el6_6.x86_64.rpm

Preparing... ########################################### [100%]1:mysql-devel ########################################### [100%]

使用service命令查看MySQL安装状态:

[root@RD-viPORTAL-1mysql]# service mysqld status

mysqld 已停

使用service命令启动MySQL并初始化:

[root@RD-viPORTAL-1mysql]# service mysqld start

初始化 MySQL 数据库: Installing MySQL system tables...

OK

Filling help tables...

OK

To start mysqld at boottimeyou have to copy

support-files/mysql.server to the right place foryour system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER!Todo so, start the server, thenissue the following commands:/usr/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h RD-viPORTAL-1 password 'new-password'Alternatively you can run:/usr/bin/mysql_secure_installationwhichwill also give you the option of removing the test

databases and anonymous user created by default. This is

strongly recommendedforproduction servers.

See the manualfor moreinstructions.

You can start the MySQL daemon with:

cd/usr ; /usr/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.pl

cd/usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the/usr/bin/mysqlbug script![确定]

正在启动 mysqld: [确定]

[root@RD-viPORTAL-1 mysql]#

查询3306端口确认是否正常启动:

[root@RD-viPORTAL-1 mysql]# netstat -an|grep 3306tcp0 0 0.0.0.0:3306 0.0.0.0:*LISTEN

unix2 [ ACC ] STREAM LISTENING 19314 /tmp/orbit-gdm/linc-c5a-0-4d33062e40154

unix3 [ ] STREAM CONNECTED 19323 /tmp/orbit-gdm/linc-c5a-0-4d33062e40154

unix3 [ ] STREAM CONNECTED 19320 /tmp/orbit-gdm/linc-c5a-0-4d33062e40154

MySQL默认配置路径:

[root@RD-viPORTAL-1 mysql]# cd /var/lib/mysql/[root@RD-viPORTAL-1mysql]# ll

总用量20488

-rw-rw---- 1 mysql mysql 10485760 2月 15 05:52ibdata1-rw-rw---- 1 mysql mysql 5242880 2月 15 05:52ib_logfile0-rw-rw---- 1 mysql mysql 5242880 2月 15 05:52ib_logfile1

drwx------ 2 mysql mysql 4096 2月 15 05:52mysql

srwxrwxrwx1 mysql mysql 0 2月 15 05:52mysql.sock

drwx------ 2 mysql mysql 4096 2月 15 05:52 test

三、配置MySQL

设置root用户密码

默认情况下MySQL是不需要登录密码的,为安全起见,设置MySQL密码。

[root@RD-viPORTAL-1 mysql]# mysqladmin -u root password "passw0rd"

此时直接登录显示访问拒绝:

[root@RD-viPORTAL-1mysql]# mysql

ERROR1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

使用如下命令登录MySQL:

[root@RD-viPORTAL-1 mysql]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connectionid is 10Server version:5.1.73Source distribution

Copyright (c)2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type'help;' or '\h' for help. Type '\c' to clearthe current input statement.

mysql> select *from user;

ERROR1046(3D000): No database selected

mysql>exit

Bye

授权root用户可以远程访问:

[root@RD-viPORTAL-1 mysql]# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connectionid is 12Server version:5.1.73Source distribution

Copyright (c)2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type'help;' or '\h' for help. Type '\c' to clearthe current input statement.

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

Query OK,0 rows affected (0.00sec)

mysql>exit

Bye

[root@RD-viPORTAL-1 mysql]#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值