Centos6.8 安装MySQL5.7
来源:互联网 发布:欧莱雅数据库营销案例 编辑:程序博客网 时间:2024/06/06 19:56
卸载系统自带mysql
查找系统自带mysql
rpm -qa|grep mysql
卸载
rpm -e –nodeps …
官网下载安装包
移动安装包到/usr/local目录下
mv mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz /usr/local
解压安装包
cd /usr/local
tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
删除压缩包
rm -rf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
重命名解压文件目录
mv mysql-5.7.19-linux-g
创建data目录
cd mysql
mkdir data
创建mysql的用户组和用户,并对mysql目录设置用户组和用户
[root@localhost local]# groupadd mysql[root@localhost local]# useradd mysql -M -g mysql[root@localhost local]# cd mysql[root@localhost mysql]# pwd/usr/local/mysql[root@localhost mysql]# chown -R mysql .[root@localhost mysql]# chgrp -R mysql .
初始化mysql
[root@localhost mysql]# cd /usr/local/mysql/bin[root@localhost bin]# yum install libaio已加载插件:fastestmirror, refresh-packagekit, security设置安装进程Loading mirror speeds from cached hostfile* base: mirrors.opencas.cn* extras: mirrors.btte.net* updates: mirrors.btte.net包 libaio-0.3.107-10.el6.i686 已安装并且是最新版本无须任何处理[root@localhost bin]# ./mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize2017-11-22T10:28:58.907531Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2017-11-22T10:29:00.490280Z 0 [Warning] InnoDB: New log files created, LSN=457902017-11-22T10:29:00.882493Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2017-11-22T10:29:01.096011Z 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: f4a678b6-cf6f-11e7-919a-645a046ecd85.2017-11-22T10:29:01.123741Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.2017-11-22T10:29:01.136683Z 1 [Note] A temporary password is generated for root@localhost: 9&I-yvDP.3Dn
启动mysql服务
[root@localhost mysql]# cd support-files/[root@localhost support-files]# ./mysql.server startStarting MySQL.Logging to '/usr/local/mysql/data/localhost.err'.. [确定]
登录mysql
[root@localhost support-files]# mysql -u root -p
输入密码:9&I-yvDP.3Dn
若出现
[root@localhost support-files]# mysql -u root -pbash: mysql: command not found[root@localhost support-files]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
修改密码,不修改无法操作
mysql> set password=password('123456');Query OK, 0 rows affected, 1 warning (0.00 sec)
将mysqld服务加入到开机自启动项
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld[root@localhost support-files]# chkconfig --list mysqldmysqld 服务支持 chkconfig,但它在任何级别中都没有被引用(运行“chkconfig --add mysqld”)[root@localhost support-files]# chkconfig --add mysqld[root@localhost support-files]# chkconfig --list mysqldmysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
非root用户不能用mysql
[qiu@localhost 桌面]$ mysql -u root -pEnter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
解决办法:
方法一: 在/etc/profile文件中最后一行添加变量export PATH=$PATH:/usr/local/mysql/bin【对所有用户生效(永久的)】 用VI在文件/etc/profile文件中增加变量,该变量将会对Linux下所有用户有效,并且是“永久的”。 要让刚才的修改马上生效,需要执行以下代码 # source /etc/profile 方法二: 在用户目录下的.bash_profile文件中增加变量【对单一用户生效(永久的)】 用VI在用户目录下的.bash_profile文件中增加变量,改变量仅会对当前用户有效,并且是“永久的”。 要让刚才的修改马上生效,需要在用户目录下执行以下代码 # source .bash_profile 方法三: 直接运行export命令定义变量【只对当前shell(BASH)有效(临时的)】 在shell的命令行下直接使用[export变量名=变量值]定义变量,该变量只在当前的shell(BASH)或其子shell(BASH)下是有效的,shell关闭了,变量也就失效了,再打开新shell时就没有这个变量,需要使用的话还需要重新定义。 例如:export PATH=$PATH:/usr/local/mysql/bin
配置
vim /etc/my.cnf[mysqld]basedir = /usr/local/mysqldatadir = /usr/local/mysql/datacharacter_set_server=utf8init_connect='SET NAMES utf8'[client]default-character-set=utf8
重启mysql服务
service mysqld restart
阅读全文
0 0
- centos6.8 安装mysql5.7
- Centos6.8 安装MySQL5.7
- Centos6.8通过yum安装mysql5.7
- Centos6.8通过yum安装mysql5.7
- centos6.8 64 安装 mysql5.7
- Centos6.8通过yum安装mysql5.7
- Centos6.8通过yum安装mysql5.7
- centos6.8源码安装mysql5.7
- CentOS6/7安装MySQL5.7
- CentOs6.8 安装 mysql5.7.17
- centos6.8安装mysql5.6
- Centos6.8安装Mysql5.6
- centos6.5 安装 MySQL5.7
- centos6.5安装mysql5.7
- centos6.7 安装 mysql5.6
- linux(centos6) 安装mysql5.7
- centOS6.6 安装 MySQL5.7
- CentOS6.5安装mysql5.7
- 深度学习---之pooling层的作用与缺陷
- Linux命令
- robotframework自动化系列:删除操作流程以及总结
- ART异常处理机制(2)
- hibernate框架的查询优化(二十三)
- Centos6.8 安装MySQL5.7
- strings.xml里字符串拼接、占位符和常用替换符号
- log4j
- ListView中嵌套(ListView)控件时item的点击事件不起作的问题解决方法
- 排序算法总结
- 【JDK1.8】JDK1.8集合源码阅读——TreeMap(一)
- 封装RxJava+Retrofit+OkHttp
- 横竖屏切换时候Activity的生命周期
- Golang源码探索(三) GC的实现原理