Centos7通过yum安装最新MySQL

一:去官网查看最新安装包

https://dev.mysql.com/downloads/repo/yum/

二:下载MySQL源安装包

wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

安装MySql源

yum -y install mysql57-community-release-el7-11.noarch.rpm

查看一下安装效果

yum repolist enabled | grep mysql.*

三:安装MySQL服务器

yum module disable mysql (sudo yum install disable mysql

yum install mysql-community-server

中间会弹出是与否的选择,选择y即可,然后耐心等待吧。。。。。。。

四:启动MySQL服务

systemctl start  mysqld.service  或者  (service mysqld start

运行一下命令查看一下运行状态 

systemctl status mysqld.service

五:初始化数据库密码

查看一下初始密码

grep "password" /var/log/mysqld.log

登录

mysql -uroot -p

修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY '****************';

mysql默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误

六:数据库授权

数据库没有授权,只支持localhost本地访问

mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

//远程连接数据库的时候需要输入用户名和密码

用户名:root

密码:123456

指点ip:%代表所有Ip,此处也可以输入Ip来指定Ip

输入后使修改生效还需要下面的语句

mysql>FLUSH PRIVILEGES;

也可以通过修改表来实现远程:

    mysql -u root -p

    mysql> use mysql; 
    mysql> update user set host = '%' where user = 'root'; 
    mysql> select host, user from user;

七:设置自动启动

systemctl enable mysqld

systemctl daemon-reload

八:启动和停止mysql服务

systemctl start mysqld     启动

systemctl stop mysqld     停止

systemctl restart mysqld     重启

以下是修改数据库忽略大小写:

1.windows下

到安装mysql的目录,修改my.ini文件

在文件最后一行加上下面一句话

lower_case_table_names=1

lower_case_table_names = 1
说明 0:区分大小写,1:不区分大小写

2.linux环境下

进入etc下面

cd /etc/

编辑my.cnf文件

vi my.cnf

最后一行加上下面一句

lower_case_table_names=1

保存:

:wq

# 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
lower_case_table_names=1

重启mysql:

systemctl restart mysqld

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值