首页 > 数据库 > MySQL >

centOS7上的mysql安装

2017-05-06

centOS7上的mysql安装。

centOS7上的mysql安装。

.Linux上安装MYSQL

1:首先下载RPM文件(mysql57-community-release-el7-8.noarch.rpm)

2:可以在这里下载:http://dev.mysql.com/downloads/repo/yum/

3:安装RPM文件: rpm -Uvh mysql57-community-release-el7-8.noarch.rpm

4:安装:

yum install mysql-community-server

5:启动MySQL:systemctl start mysqld.service

6:查看初始密码: grep 'temporary password' /var/log/mysqld.log

红色框里的就是初始密码

7:登录MySQL: mysql -uroot -p ,会提示输入密码,将上面的密码输入。

8:登录成功后第一步要更改密码:ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

注意:密码必须要有大写字母,小写字母,数字以及特殊字符,最少8位。

9:登录成功后默认远程是不能连接到MySQL的,需要设置一下。

use mysql; 进入mysql系统数据库

select Host, User from user; 查询用户表,可以看到root用户只有localhost可以访问。需要改成可以远程登录。

update user set host = '%' where user='root';

flush privileges; 最后执行更新权限语句。

10:使用远程客户端可以访问MySQL了。

vim /etc/my.cnf

# 修改处1:添加以下2行

[client]

default-character-set=utf8

[mysqld]

#skip-grant-tables

#skip-networking

#

# 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

# 修改处2:添加以下3行

default-storage-engine=INNODB

character-set-server=utf8

collation-server=utf8_general_ci

lower_case_table_names=1

相关文章
最新文章
热点推荐