分享更有价值
被信任是一种快乐

在Linux 6.3如何安装mysql5.7.16数据库

文章页正文上

这篇文章主要介绍了在Linux 6.3如何安装mysql5.7.16数据库,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
1、下载安装包
http://dev.mysql.com/downloads/
2.检查库文件是否存在,如有删除。
[root@QuDaoMysql mysql]# rpm -qa | grep mysql
mysql-5.1.61-4.el6.x86_64
qt-mysql-4.6.2-24.el6.x86_64
mysql-server-5.1.61-4.el6.x86_64
mysql-libs-5.1.61-4.el6.x86_64
mysql-devel-5.1.61-4.el6.x86_64
[root@QuDaoMysql mysql]#
[root@QuDaoMysql mysql]# rpm -e mysql-5.1.61-4.el6.x86_64 –nodeps
[root@QuDaoMysql mysql]# rpm -e qt-mysql-4.6.2-24.el6.x86_64 –nodeps
[root@QuDaoMysql mysql]# rpm -e mysql-server-5.1.61-4.el6.x86_64 –nodeps
[root@QuDaoMysql mysql]# rpm -e mysql-libs-5.1.61-4.el6.x86_64 –nodeps
[root@QuDaoMysql mysql]# rpm -e mysql-devel-5.1.61-4.el6.x86_64 –nodeps
[root@QuDaoMysql mysql]#

3.检查mysql组和用户是否存在,如无创建。
[root@QuDaoMysql mysql]# cat /etc/group | grep mysql
mysql:x:27:
[root@QuDaoMysql mysql]# cat /etc/passwd | grep mysql
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash

注意安装顺序
rpm -ivh mysql-community-common-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.16-1.el6.x86_64.rpm

[root@QuDaoMysql _rpminstall]# rp免费主机域名m -ivh mysql-community-common-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-common-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing… ########################################### [100%]
1:mysql-community-common ########################################### [100%]
[root@QuDaoMysql _rpminstall]# rpm -ivh mysql-community-libs-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-libs-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing… ########################################### [100%]
1:mysql-community-libs ########################################### [100%]
[root@QuDaoMysql _rpminstall]# rpm -ivh mysql-community-client-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-client-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing… ########################################### [100%]
1:mysql-community-client ########################################### [100%]
[root@QuDaoMysql _rpminstall]# rpm -ivh mysql-community-server-5.7.16-1.el6.x86_64.rpm
warning: mysql-community-server-5.7.16-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing… ########################################### [100%]
1:mysql-community-server warning: /etc/my.cnf created as /etc/my.cnf.rpmnew
########################################### [100%]
[root@QuDaoMysql _rpminstall]#

安装过程中会生成my.cnf,手动把原来的覆盖

[root@QuDaoMysql _rpminstall]# cp /etc/my.cnf.rpmnew /etc/my.cnf
cp: overwrite `/etc/my.cnf’? y
[root@QuDaoMysql _rpminstall]#

4、启动mysql

[root@QuDaoMysql _rpminstall]# /etc/rc.d/init.d/mysqld start
Initializing MySQL database: [ OK ]
Installing validate password plugin: [ OK ]
Starting mysqld: [ OK ]
[root@QuDaoMysql _rpminstall]#

5、mysql5.7 开始有默认的密码
[root@QuDaoMysql _rpminstall]# cat /var/log/mysqld.log|grep ‘temporary password’
2016-10-20T03:07:36.130787Z 1 [Note] A temporary password is generated for root@localhost: EGlLlD,dg2qe
[root@QuDaoMysql _rpminstall]#

初始密码为 EGlLlD,dg2qe

6、登录
输入密码,重置密码
[root@QuDaoMysql _rpminstall]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.7.16

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

Oracle is a registered tr免费主机域名ademark 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>
mysql> SET PASSWORD = PASSWORD(‘xxxxxx’);
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql>
mysql> SET PASSWORD = PASSWORD(‘xxxxxxx’);
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>

7、授权远程连接
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘xxxxx’ WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql>

说明:如果远程连接不上,关闭防火墙。

8.配置mysql自动启动
# chkconfig –level 345 mysqld on —设置MySQL在345等级自动启动

9.修改默认目录
关闭数据库
[root@QuDaoMysql prlife]# service mysqld stop
Stopping mysqld: [ OK ]
[root@QuDaoMysql prlife]# cd /var/lib/

拷贝必须使用-a,否则权限会乱掉
[root@QuDaoMysql lib]# cp -a mysql /prlife/

修改第一个文件
修改/etc/my.cnf,修改前需要进行备份

#datadir=/var/lib/mysql
#socket=/var/lib/mysql/mysql.sock
datadir=/prlife/mysql/data
socket=/prlife/mysql/data/mysql.sock

再增加以下几个参数,否则会报错
[mysql.server]
user=mysql
basedir=/prlife/mysql/data/mysql
[client]
socket=/prlife/mysql/data/mysql.sock

修改第二个文件:mysqld

修改之前进行备份
[root@QuDaoMysql mysql]# cp /etc/init.d/mysqld /etc/init.d/mysqld_bak
[root@QuDaoMysql mysql]# vi /etc/init.d/mysqld
替换所有 /var/lib/mysql为/prlife/mysql/data

修改第三个文件
修改之前先备份
cp /usr/bin/mysqld_safe /usr/bin/mysqld_safebak
vi /usr/bin/mysqld_safe
替换所有 /var/lib/mysql为 /prlife/mysql/data

(4)创建一个mysql.sock的链接

[root@QuDaoMysql lib]# mkdir -p /var/lib/mysql/
[root@QuDaoMysql lib]# chown -R mysql.mysql /var/lib/mysql
[root@QuDaoMysql lib]# ln -s /prlife/mysql/data/mysql.sock /var/lib/mysql/mysql.sock

重启数据库
感谢你能够认真阅读完这篇文章,希望小编分享的“在Linux 6.3如何安装mysql5.7.16数据库”这篇文章对大家有帮助,同时也希望大家多多支持云技术,关注云技术行业资讯频道,更多相关知识等着你来学习!

相关推荐: mysql中更新锁与排它锁的示例分析

这篇文章将为大家详细讲解有关mysql中更新锁与排它锁的示例分析,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。一直没有认真了解UPDATE操作的锁,最近在MSDN论坛上看到一个问题,询问堆表更新的死锁问题,问题很简单,有类似…

文章页内容下
赞(0) 打赏
版权声明:本站采用知识共享、学习交流,不允许用于商业用途;文章由发布者自行承担一切责任,与本站无关。
文章页正文下
文章页评论上

云服务器、web空间可免费试用

宝塔面板主机、支持php,mysql等,SSL部署;安全高速企业专供99.999%稳定,另有高防主机、不限制内容等类型,具体可咨询QQ:360163164,Tel同微信:18905205712

主机选购导航云服务器试用

登录

找回密码

注册