在Linux6.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]# rpm -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 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>
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数据库”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联-成都网站建设公司行业资讯频道,更多相关知识等着你来学习!
网页名称:在Linux6.3如何安装mysql5.7.16数据库-创新互联
当前链接:http://ybzwz.com/article/coihcs.html