1
增加/etc/yum.repo.d/mysql-community.repo
[mysql56-community]name=MySQL 5.6 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/enabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
2
执行yum安装
sudo yum install -y mysql-community-server
3
修改配置文件
vi etc/my.cnf
[mysqld]socket = data/mysql/mysql.sockdefault-time-zOne= '+8:00'key_buffer_size = 1024Mmax_allowed_packet = 16Mtable_open_cache = 1024sort_buffer_size = 128Mread_buffer_size = 128Mread_rnd_buffer_size = 32Mmyisam_sort_buffer_size = 364Mmyisam_max_sort_file_size = 10Gthread_cache_size = 64query_cache_size= 256Mquery_cache_type=1query_cache_limit=2Minnodb_thread_cOncurrency= 16max_cOnnections=1000max_connect_errors=10000max_heap_table_size = 64Mtmp_table_size = 32Mft_min_word_len=1ft_stopword_file=delay_key_write=ALLtmp_table_size=800Mtmpdir = tmp/skip-name-resolvewait_timeout = 28800interactive_timeout = 28800group_concat_max_len = 102400character-set-server=utf8server-id = 81binlog_format = rowlog-error=/data/mysql/2_7_81-error.logpid-file=/data/mysql/2_7_81.piddatadir = data/mysql/log-bin=/data/mysql/2_7_81-binlog-bin-index=/data/mysql/2_7_81-bin.indexlog_bin_trust_function_creators=1log_slave_updatesexpire_logs_days=15relay-log=/data/mysql/2_7_81-srelay.logrelay_log_purge=1slow_query_log = 1slow_query_log_file=/data/mysql/2_7_81-slowquery.loglong_query_time=10innodb_file_per_table=1innodb_write_io_threads=8innodb_read_io_threads=8innodb_lock_wait_timeout=300innodb_large_prefix=onft_min_word_len = 1sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION[mysqldump]quickmax_allowed_packet=512Mdefault-character-set=utf8[mysql]no-auto-rehash[isamchk]key_buffer = 256Msort_buffer_size = 256Mread_buffer = 2Mwrite_buffer = 2M[myisamchk]key_buffer = 256Msort_buffer_size = 256Mread_buffer = 2Mwrite_buffer = 2M[client]socket = /data/mysql/mysql.sock
[mysqld]
socket = data/mysql/mysql.sock
default-time-zOne= '+8:00'
key_buffer_size = 1024M
max_allowed_packet = 16M
table_open_cache = 1024
sort_buffer_size = 128M
read_buffer_size = 128M
read_rnd_buffer_size = 32M
myisam_sort_buffer_size = 364M
myisam_max_sort_file_size = 10G
thread_cache_size = 64
query_cache_size= 256M
query_cache_type=1
query_cache_limit=2M
innodb_thread_cOncurrency= 16
max_cOnnections=1000
max_connect_errors=10000
max_heap_table_size = 64M
tmp_table_size = 32M
ft_min_word_len=1
ft_stopword_file=
delay_key_write=ALL
tmp_table_size=800M
tmpdir = tmp/
skip-name-resolve
wait_timeout = 28800
interactive_timeout = 28800
group_concat_max_len = 102400
character-set-server=utf8
server-id = 81
binlog_format = row
log-error=/data/mysql/2_7_81-error.log
pid-file=/data/mysql/2_7_81.pid
datadir = data/mysql/
log-bin=/data/mysql/2_7_81-bin
log-bin-index=/data/mysql/2_7_81-bin.index
log_bin_trust_function_creators=1
log_slave_updates
expire_logs_days=15
relay-log=/data/mysql/2_7_81-srelay.log
relay_log_purge=1
slow_query_log = 1
slow_query_log_file=/data/mysql/2_7_81-slowquery.log
long_query_time=10
innodb_file_per_table=1
innodb_write_io_threads=8
innodb_read_io_threads=8
innodb_lock_wait_timeout=300
innodb_large_prefix=on
ft_min_word_len = 1
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[mysqldump]
quick
max_allowed_packet=512M
default-character-set=utf8
[mysql]
no-auto-rehash
[isamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
[client]
socket = /data/mysql/mysql.sock
主要修改datadir、socket的路径
4
启动mysql
service mysqld restart
5
设置不用密码就可以登录
mysql能够正常启动后,先修改/etc/my.cnf,在[mysqld]下添加skip-grant-tables,意思是数据库启动的时候 跳跃权限表的限制,不用验证密码,直接登录
[myslqd]...skip-grant-tables...
[myslqd]
...
skip-grant-tables
保存后重启服务
6
登录
mysql -uroot -p
直接回车就可以登录进去
7
修改root密码
登录后,执行
update mysql.user set authentication_string=password('123456') where user= 'root'; FLUSH PRIVILEGES;
update mysql.user set authentication_string=password('123456') where user= 'root';
FLUSH PRIVILEGES;
即:设置root用户的密码是123456。下次登录就可以使用密码登录。注意要将/etc/my.cnf中skip-grant-tables去掉,并重启mysqld服务
8
注意
通过密码登录后,可能会提示要reset用户的密码,需要执行下面重置密码的命令:
alter user 'root'@'localhost' identified by '123456';
如果执行失败,提示密码策略错误,说明当前的密码不满足默认的策略,要么修改的密码包含字母、数字、特殊字符。要么修改默认的密码策略:
set global validate_password.policy=0; #设置为弱口令
/
关
注
我
们
/ 微信号 / 程序老哥/