我是靠谱客的博主 慈祥棒球,最近开发中收集的这篇文章主要介绍linux 非root安装mysql,1、mysql:centos6安装mysql5.7(yum非root用户),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1.卸载mysql

1.1.查找是否安装了MySQL

rpm -qa | grep -i mysql

23fa4289bcdb

image.png

1.2.卸载

sudo rpm -e --nodeps mysql-libs-5.1.73-8.el6_8.x86_64

2.获取mysql文件注意这里的el6-10即适配RHEL(Red Hat Enterprise Linux)6.10的版本,如果下载了其它版本后面的安装过程中可能会报错)

3.安装第二步下载的rpm文件

[bigdata@hdp-slave1 etc]$ sudo yum -y localinstall mysql57-community-release-el6-10.noarch.rpm

23fa4289bcdb

image.png

4.装MySQL服务

[bigdata@hdp-slave2 etc]$ sudo yum -y install mysql-community-server

23fa4289bcdb

image.png

5.启动mysql

[bigdata@hdp-slave1 etc]$ sudo service mysqld start

23fa4289bcdb

image.png

6.1.获取初始化密码(未成功,采用的6.2方法)

[bigdata@hdp-slave1 etc]$ sudo grep "password" /var/log/mysqld.log

23fa4289bcdb

密码获取成功

mysql> set global validate_password_policy=0;#降低密码难易程度

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('pythonniu');

23fa4289bcdb

强制修改密码,并设置降低密码难易程度

6.2.开启无密码登录模式,并修改密码,设置远程访问权限

[bigdata@hdp-slave1 etc]$ sudo grep "password" /var/log/mysqld.log

23fa4289bcdb

密码获取失败.png

1).开启无密码登录模式,并修改密码

[bigdata@hdp-slave1 etc]$ cd /etc/

[bigdata@hdp-slave1 etc]$ sudo vi my.cnf

在[mysqld]这个条目下加入 skip-grant-tables 保存退出后重启mysql

[bigdata@hdp-slave1 etc]$ sudo service mysqld restart

[bigdata@hdp-slave1 etc]$ mysql -u root -p

mysql> use mysql;

mysql> update user set password=password("新密码") where user="root";

23fa4289bcdb

image.png

2)设置远程访问权限

任何主机

mysql>GRANT ALL PRIVILEGES ON . TO 'root'@'%' IDENTIFIED BY '你的密码' WITH GRANT OPTION;

刷新权限

mysql>flush privileges;

7.设置字符集

修改my.cnf

新添加[mysql],补充[mysqld],对照以下内容

[mysql]

default-character-set=utf8

[mysqld]

#设置utf8编码

character-set-server = utf8

collation-server = utf8_general_ci

skip-character-set-client-handshake

#MYSQL设置不区分大小写

lower_case_table_names=1

8.原始my.cnf文件展示

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]

#

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

#

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

#

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

[bigdata@hdp-slave2 etc]$ cat my.cnf.bak

# For advice on how to change settings please see

# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]

#

# Remove leading # and set to the amount of RAM for the most important data

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.

# innodb_buffer_pool_size = 128M

#

# Remove leading # to turn on a very important data integrity option: logging

# changes to the binary log between backups.

# log_bin

#

# Remove leading # to set options mainly useful for reporting servers.

# The server defaults are faster for transactions and fast SELECTs.

# Adjust sizes as needed, experiment to find the optimal values.

# join_buffer_size = 128M

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

最后

以上就是慈祥棒球为你收集整理的linux 非root安装mysql,1、mysql:centos6安装mysql5.7(yum非root用户)的全部内容,希望文章能够帮你解决linux 非root安装mysql,1、mysql:centos6安装mysql5.7(yum非root用户)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部