当前位置: 移动技术网 > IT编程>数据库>Mysql > 阿里云 Centos7.3安装mysql5.7.18 rpm安装教程

阿里云 Centos7.3安装mysql5.7.18 rpm安装教程

2017年12月07日  | 移动技术网IT编程  | 我要评论

转轮手枪,河南卫视武林风播出时间,伤感情感文章

卸载mariadb

centos7默认安装mariadb而不是mysql,而且yum服务器上也移除了mysql相关的软件包。因为mariadb和mysql可能会冲突,故先卸载mariadb。

1、安装新版mysql之前,我们需要将系统自带的mariadb-lib卸载

[root@izwz94qazh62gk5ewl4ei2z home]# rpm -qa | grep -i mariadb
 mariadb-libs-5.5.52-1.el7.x86_64
[root@izwz94qazh62gk5ewl4ei2z home]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64

2、到mysql的官网下载最新版mysql的rpm集合包:mysql-5.7.18-1.el6.x86_64.rpm-bundle.tar

3、上传mysql-5.7.18-1.el6.x86_64.rpm-bundle.tar到linux服务器,并解压tar包

[root@izwz94qazh62gk5ewl4ei2z home]# mkdir mysql
[root@izwz94qazh62gk5ewl4ei2z home]# tar -xf mysql-5.7.18-1.el6.x86_64.rpm-bundle.tar -c mysql
[root@izwz94qazh62gk5ewl4ei2z home]# cd mysql
[root@izwz94qazh62gk5ewl4ei2z mysql]# ll
total 459492
-rw-r--r-- 1 7155 31415 23618836 mar 20 17:40 mysql-community-client-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415  335496 mar 20 17:40 mysql-community-common-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415  3747352 mar 20 17:40 mysql-community-devel-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 39086508 mar 20 17:40 mysql-community-embedded-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 135869292 mar 20 17:40 mysql-community-embedded-devel-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415  2177064 mar 20 17:40 mysql-community-libs-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415  1723180 mar 20 17:40 mysql-community-libs-compat-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 159060212 mar 20 17:41 mysql-community-server-5.7.18-1.el6.x86_64.rpm
-rw-r--r-- 1 7155 31415 104881084 mar 20 17:41 mysql-community-test-5.7.18-1.el6.x86_64.rpm

4、使用rpm -ivh命令进行安装

[root@izwz94qazh62gk5ewl4ei2z mysql]# rpm -ivh mysql-community-common-5.7.18-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.18-1.el6.x86_64.rpm: header v3 dsa/sha1 signature, key id 5072e1f5: nokey
preparing...             ################################# [100%]
updating / installing...
  1:mysql-community-common-5.7.18-1.e################################# [100%]
[root@izwz94qazh62gk5ewl4ei2z mysql]# rpm -ivh mysql-community-libs-5.7.18-1.el6.x86_64.rpm
warning: mysql-community-libs-5.7.18-1.el6.x86_64.rpm: header v3 dsa/sha1 signature, key id 5072e1f5: nokey
preparing...             ################################# [100%]
updating / installing...
  1:mysql-community-libs-5.7.18-1.el6################################# [100%]
[root@izwz94qazh62gk5ewl4ei2z mysql]# rpm -ivh mysql-community-client-5.7.18-1.el6.x86_64.rpm
warning: mysql-community-client-5.7.18-1.el6.x86_64.rpm: header v3 dsa/sha1 signature, key id 5072e1f5: nokey
preparing...             ################################# [100%]
updating / installing...
  1:mysql-community-client-5.7.18-1.e################################# [100%]
[root@izwz94qazh62gk5ewl4ei2z mysql]# rpm -ivh mysql-community-server-5.7.18-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.18-1.el6.x86_64.rpm: header v3 dsa/sha1 signature, key id 5072e1f5: nokey
preparing...             ################################# [100%]
updating / installing...
  1:mysql-community-server-5.7.18-1.e################################# [100%]
[root@izwz94qazh62gk5ewl4ei2z mysql]# 

上面几个包有依赖关系,执行有先后。

使用rpm安装方式安装mysql,安装的路径如下:

a 数据库目录
/var/lib/mysql/
b 配置文件
/usr/share/mysql(mysql.server命令及配置文件)
c 相关命令
/usr/bin(mysqladmin mysqldump等命令)
d 启动脚本
/etc/rc.d/init.d/(启动脚本文件mysql的目录)
e /etc/my.conf

5、 数据库初始化

为了保证数据库目录为与文件的所有者为 mysql 登陆用户,如果你的linux系统是以 root 身份运行 mysql 服务,需要执行下面的命令初始化

[root@izwz94qazh62gk5ewl4ei2z mysql]# mysqld --initialize --user=mysql

如果是以 mysql 身份登录运行,则可以去掉 --user 选项。

另外 --initialize 选项默认以“安全”模式来初始化,则会为 root 用户生成一个密码并将该密码标记为过期,登陆后你需要设置一个新的密码,

而使用 --initialize-insecure 命令则不使用安全模式,则不会为 root 用户生成一个密码。

这里演示使用的 --initialize 初始化的,会生成一个 root 账户密码,密码在log文件里,红色区域的就是自动生成的密码

[root@izwz94qazh62gk5ewl4ei2z mysql]# cat /var/log/mysqld.log
2017-06-05t14:30:52.709474z 0 [warning] timestamp with implicit default value is deprecated. please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-06-05t14:30:55.590590z 0 [warning] innodb: new log files created, lsn=45790
2017-06-05t14:30:56.000269z 0 [warning] innodb: creating foreign key constraint system tables.
2017-06-05t14:30:56.109868z 0 [warning] no existing uuid has been found, so we assume that this is the first time that this server has been started. generating a new uuid: 960c533e-49fb-11e7-91f2-00163e089fd2.
2017-06-05t14:30:56.116186z 0 [warning] gtid table is not ready to be used. table 'mysql.gtid_executed' cannot be opened.
2017-06-05t14:30:56.116777z 1 [note] a temporary password is generated for root@localhost: :wu?2qqutqwj

 现在启动mysql数据库systemctl start mysqld.service(centos7特有的启动方式)

[root@izwz94qazh62gk5ewl4ei2z mysql]# systemctl start mysqld.service

可以使用下面两个命令对mysql进行停止,启动和重启:

启动:

使用 service 启动:service mysqld start
使用 mysqld 脚本启动:/etc/inint.d/mysqld start
使用 safe_mysqld 启动:safe_mysqld&

停止:

使用 service 启动:service mysqld stop
使用 mysqld 脚本启动:/etc/inint.d/mysqld stop
mysqladmin shutdown

重启:

使用 service 启动:service mysqld restart
使用 mysqld 脚本启动:/etc/inint.d/mysqld restart

连接数据库

[root@izwz94qazh62gk5ewl4ei2z mysql]# mysql -u root -p
enter password:

密码输入:  :wu?2qqutqwj

修改密码:

set password = password('你的密码');
设置远程访问

grant all privileges on *.* to 'root' @'%' identified by '123456'; 
flush privileges;

设置mysql开机启动

加入到系统服务:

chkconfig --add mysql

自动启动:

chkconfig mysql on

查询列表:

chkconfig

说明:都没关闭(off)时是没有自动启动。

以上所述是小编给大家介绍的阿里云 centos7.3安装mysql5.7.18 rpm安装教程,希望对大家有所帮助

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网