查是否安装了mysql:
centos6:
rpm -qa |grep mysql
centos7:
rpm -qa|grep mariadb
或rpm -qa |grep mysql

有老的版本可以执行命令卸载:

rpm -e --nodeps mysql-libs

1、设置源

cat > /etc/yum.repos.d/mysql-community-el7.repo<<'EOF'

[mysql57-community]

name=MySQL 5.7 Community Server

baseurl=http://mirror.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el7/

enabled=1

gpgcheck=0

EOF

2. 安装mysql

yum install mysql-community-server -y

systemctl restart mysqld

# mysqld.log中查询密码

grep password /var/log/mysqld.log

2019-04-09T07:28:44.292450Z 1 [Note] A temporary password is generated for root@localhost: wg:V45ci4ljpz!r

3.改/etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
transaction-isolation = READ-COMMITTED
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
symbolic-links = 0
character-set-server=utf8 #设置默认字符格式
key_buffer_size = 32M
max_allowed_packet = 32M
thread_stack = 256K
thread_cache_size = 64
query_cache_limit = 8M
query_cache_size = 64M
query_cache_type = 1

max_connections = 550
#expire_logs_days = 10
#max_binlog_size = 100M

#log_bin should be on a disk with enough free space.
#Replace '/var/lib/mysql/mysql_binary_log' with an appropriate path for your
#system and chown the specified folder to the mysql user.
#log_bin=/var/lib/mysql/mysql_binary_log #如主从需打开

#In later versions of MySQL, if you enable the binary log and do not set
#a server_id, MySQL will not start. The server_id must be unique within
#the replicating group.
#server_id=1 #如主从需打开

#binlog_format = mixed #如主从需打开

read_buffer_size = 256M #并发多可调大
read_rnd_buffer_size = 64M
sort_buffer_size = 64M
join_buffer_size = 64M

# InnoDB settings
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_buffer_pool_size = 2G #并发多可调大
innodb_thread_concurrency = 8
innodb_flush_method = O_DIRECT
innodb_log_file_size = 512M

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

sql_mode=STRICT_ALL_TABLES

4.重启

#登陆后修改成自己的密码:

mysql> alter user user() identified by 'test123456';

5、 查看授权情况

select user,host from mysql.user;

最新文章

  1. mvc过滤器学习(1)
  2. 你所不知道的linq
  3. android 一些常用开源框架
  4. C#委托与事件初探
  5. 弹层组件-layer
  6. mint安装相关数据库lib
  7. WPF combobox
  8. 对于c语言int类型和float,以及double类型表示范围的计算
  9. 20160824_CentOS6.4x64_关闭IPv6
  10. Event Logging
  11. jQuery选择器解释和说明
  12. ASP.NET文件上传的三种基本方法
  13. JavaSctipr 兼容、技巧、牛角尖
  14. MySQL在Windows和Linux减少数据库
  15. Lua的数学函数
  16. BOM定时器,onresize
  17. VS2017 MVC Spring net 环境配置
  18. LogParse-Windows系统日志分析
  19. 2018ICPC青岛 E - Plants vs. Zombies (二分+模拟)
  20. pandas 索引与列相互转化

热门文章

  1. JavaScript赋值运算符
  2. js差异化继承
  3. http状态码301和302详解及区别——辛酸的探索之路
  4. Java中的Error和Exception
  5. 记一次期待已久的渗透 从phpcms到thinkphp
  6. 移动端隐藏scroll滚动条::-webkit-scrollbar
  7. 【Spring】mvc:annotation-driven 使用
  8. SAX解析示例代码和原理
  9. AutoResetEvent和ManualResetEvent(多线程操作)
  10. 使用Navicat为Oracle导入函数后函数显示红叉