单机版的mysql安装

查是否安装了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;

 

 

posted on 2019-11-03 11:55  锋锋2019  阅读(530)  评论(0编辑  收藏  举报

导航