首页 > 代码库 > redhat下安装mysql 5.6.20,解压zip包,查看已经安装过的mysql,卸载rpm安装包,安装mysql服务器端和客户端,修改mysql用户名,登陆mysql,启动关闭mysql
redhat下安装mysql 5.6.20,解压zip包,查看已经安装过的mysql,卸载rpm安装包,安装mysql服务器端和客户端,修改mysql用户名,登陆mysql,启动关闭mysql
2 我的电脑是Redhat 6.*版本,所以这里使用上面一个
3 解压zip包
4 安装以下几个rpm
MySQL-client-advanced-5.6.20-1.el6.x86_64.rpm
MySQL-server-advanced-5.6.20-1.el6.x86_64.rpm
5 查看已经安装过的mysql
rpm –aq | grep mysql
结果:
mysql-libs-5.1.66-2.el6_3.x86_64
mod_auth_mysql-3.0.0-11.el6_0.1.x86_64
mysql-connector-java-5.1.17-6.el6.noarch
mysql-test-5.1.66-2.el6_3.x86_64
mysql-devel-5.1.66-2.el6_3.x86_64
libdbi-dbd-mysql-0.8.3-5.1.el6.x86_64
qt-mysql-4.6.2-25.el6.x86_64(这个不用卸载)
rsyslog-mysql-5.8.10-6.el6.x86_64
mysql-bench-5.1.66-2.el6_3.x86_64
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
dovecot-mysql-2.0.9-5.el6.x86_64
php-mysql-5.3.3-22.el6.x86_64
mysql-5.1.66-2.el6_3.x86_64
mysql-server-5.1.66-2.el6_3.x86_64
说明上面这些Mysql相关的已经安装了。
6卸载上面安装过的mysql
使用rpm –e mysql –nodeps –allmatches (不理会依赖关系,删除所有上一步查出来的相同的mysql)命令卸载上面不需要的mysql
例如:
rpm -e mysql-libs-5.1.66-2.el6_3.x86_64--nodeps –allmatches
按照相同的命令对安装的其它mysql进行删除。
7将老版本的几个文件手工删除
[root@localhost mysql]# rm -f /etc/my.cnf
[root@localhost mysql]# rm -rf/var/lib/mysql
[root@localhost mysql]# rm -rf/var/share/mysql
[root@localhost mysql]# rm -rf/usr/bin/mysql*
[root@localhost mysql]#
8安装mysql服务器端
[root@localhost mysql]# rpm -ivhMySQL-server-advanced-5.6.20-1.el6.x86_64.rpm
Preparing... ###########################################[100%]
1:MySQL-server-advanced ########################################### [100%]
2014-10-12 15:22:30 0 [Warning] TIMESTAMPwith implicit DEFAULT value is deprecated. Please use--explicit_defaults_for_timestamp server option (see documentation for moredetails).
2014-10-12 15:22:30 6074 [Note] InnoDB:Using atomics to ref count buffer pool pages
2014-10-12 15:22:30 6074 [Note] InnoDB:Database physically writes the file full: wait...
2014-10-12 15:22:31 6074 [Note] InnoDB:Setting log file ./ib_logfile101 size to 48 MB
关于说明信息:
A RANDOM PASSWORD HAS BEEN SET FOR THEMySQL root USER !
You will find thatpassword in ‘/root/.mysql_secret‘.
You must changethat password on your first connect,
no other statement but ‘SET PASSWORD‘ willbe accepted.
See the manual for thesemantics of the ‘password expired‘ flag.
Also, the account for theanonymous user has been removed.
In addition, you can run:
/usr/bin/mysql_secure_installation
which will also give you the option ofremoving the test database.
This is strongly recommended for productionservers.
See the manual for more instructions.
Please report any problems athttp://bugs.mysql.com/
The latest information about MySQL isavailable on the web at
http://www.mysql.com
Support MySQL by buying support/licenses athttp://shop.mysql.com
New default config file was created as/usr/my.cnf and
will be used by default by the server whenyou start it.
You may edit this file to change serversettings
9安装mysql的客户端
[root@localhost mysql]# rpm -ivhMySQL-client-advanced-5.6.20-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-client-advanced ########################################### [100%]
10安装MySQL-devel-advanced-5.6.20-1.el6.x86_64.rpm
[root@localhost mysql]# rpm -ivhMySQL-devel-advanced-5.6.20-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-devel-advanced ########################################### [100%]
[root@localhost mysql]#
11修改mysql的密码,第一次安装的时候在,第一次安装的时候的密码文件在/root/.mysql_secret中
修改密码:
[root@localhost ~]# pwd
/root
12查看密码:cat.mysql_secret
oracle收购Mysql后,新版的mysql刚安装完mysql后不能直接输入mysql登录数据库,而是设置了默认free password密码,默认密码放在了/root/.mysql_secret文件中,登陆后需要修改密码.
13 修改密码
A启动mysql
service mysql start
B如果想关闭服务,命令是servicemysql stop
14登录服务器
mysql -u root -p
为用户设置新密码
set password=password(‘123456‘);
也可以使用脚本 /usr/bin/mysql_secure_installation进行交互式的修改mysql的root密码
15.重新启动一下redhat操作系统,然后再登陆(修改后再登陆发现登陆不了)
redhat下安装mysql 5.6.20,解压zip包,查看已经安装过的mysql,卸载rpm安装包,安装mysql服务器端和客户端,修改mysql用户名,登陆mysql,启动关闭mysql