centos 6使用rpm安装mysql 5.6

来源:互联网 发布:淘宝店铺转让 淘铺王 编辑:程序博客网 时间:2024/05/29 09:16
1:查看os版本
cat /etc/issue 
[root@localhost local]# cat /etc/issue 
Oracle Linux Server release 6.7
Kernel \r on an \m


2:查看内核
[root@localhost local]# uname -a
Linux localhost.localdomain 3.8.13-68.3.4.el6uek.x86_64 #2 SMP Tue Jul 14 15:03:36 PDT 2015 x86_64 x86_64 x86_64 GNU/Linux


3:创建目录。上传包
[root@localhost software]# ls
MySQL-5.6.35-1.el6.x86_64.rpm-bundle.tar
[root@localhost software]# pwd
/home/software


4:解压包
[root@localhost software]# tar -xvf MySQL-5.6.35-1.el6.x86_64.rpm-bundle.tar 
MySQL-test-5.6.35-1.el6.x86_64.rpm
MySQL-embedded-5.6.35-1.el6.x86_64.rpm
MySQL-devel-5.6.35-1.el6.x86_64.rpm
MySQL-shared-5.6.35-1.el6.x86_64.rpm
MySQL-client-5.6.35-1.el6.x86_64.rpm
MySQL-shared-compat-5.6.35-1.el6.x86_64.rpm
MySQL-server-5.6.35-1.el6.x86_64.rpm


5:删除系统自带的mysql包
[root@localhost software]#  rpm -qa | grep mysql 
mysql-libs-5.1.73-5.el6_6.x86_64
[root@localhost software]# yum -y remove mysql-libs-5.1* 
Complete!
[root@localhost software]# rpm -qa | grep mysql
[root@localhost software]# 


6:安装mysql
[root@localhost software]# rpm -ivh MySQL-server-5.6.35-1.el6.x86_64.rpm 
warning: MySQL-server-5.6.35-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]


[root@localhost software]# rpm -ivh MySQL-client-5.6.35-1.el6.x86_64.rpm 
warning: MySQL-client-5.6.35-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]


[root@localhost software]# rpm -ivh MySQL-devel-5.6.35-1.el6.x86_64.rpm 
warning: MySQL-devel-5.6.35-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-devel            ########################################### [100%]


6:修改参数文件
[root@localhost software]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf


7:初始化mysql
[root@localhost software]# /usr/bin/mysql_install_db 


8:强制使用root启动mysql(如果不使用强制启动会报错)
[root@localhost bin]# /usr/sbin/mysqld --user=root &
[root@localhost ~]# ps -ef | grep mysql 
root      9750  9384  0 14:04 pts/1    00:00:00 /usr/sbin/mysqld --user=root
root      9797  9772  0 14:06 pts/2    00:00:00 grep mysql
[root@localhost ~]# netstat -anpt | grep 3306
tcp        0      0 :::3306                     :::*                        LISTEN      9750/mysqld  


9:查看root的初始密码和重新设置密码
[root@localhost ~]# more /root/.mysql_secret 
# The random password set for the root user at Tue Sep  5 13:53:46 2017 (local time): 8oa2yTSLQ9QZpUtg




[root@localhost ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.35


Copyright (c) 2000, 2016, 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 clear the current input statement.


mysql> SET PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@localhost ~]# 


10:验证密码
[root@localhost ~]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.35 MySQL Community Server (GPL)


Copyright (c) 2000, 2016, 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 clear the current input statement.


mysql> 
原创粉丝点击