yum 安裝mysql5.7

wget https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm
rpm -Uvh mysql57-community-release-el6-9.noarch.rpm 
yum install mysql-community-server
service mysqld start

mysql安裝完成以後,在/var/log/mysqld.log文件中給root生成了一個默認密碼。經過下面的方式找到root默認密碼,而後登陸mysql進行修改:
grep 'temporary password' /var/log/mysqld.log

修改默認密碼
mysql -uroot -p
SET PASSWORD = PASSWORD('your new password');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
flush privileges;
添加遠程訪問
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密碼' WITH GRANT OPTION;
flush privileges;


若是發生ERROR 1819 (HY000): Your password does NOT satisfy the CURRENT policy requirements。請見:http://my.oschina.net/u/232595/blog/677466

my.cnfhtml

[client]  
port=3306  
socket=/tmp/mysql.sock  
default-character-set=utf8  
   
[mysql]  
no-auto-rehash  
default-character-set=utf8  
   
[mysqld]  
port=3306  
character-set-server=utf8  
socket=/tmp/mysql.sock  
basedir=/usr/local/mysql  
datadir=/data/mysql  
explicit_defaults_for_timestamp=true  
lower_case_table_names=1  
back_log=103  
max_connections=3000  
max_connect_errors=100000  
table_open_cache=512  
external-locking=FALSE  
max_allowed_packet=32M  
sort_buffer_size=2M  
join_buffer_size=2M  
thread_cache_size=51  
query_cache_size=32M  
#query_cache_limit=4M  
transaction_isolation=REPEATABLE-READ  
tmp_table_size=96M  
max_heap_table_size=96M  
   
###***slowqueryparameters  
long_query_time=1  
slow_query_log = 1  
slow_query_log_file=/data/slowlog/slow.log  
   
###***binlogparameters  
log-bin=mysql-bin  
binlog_cache_size=4M  
max_binlog_cache_size=8M  
max_binlog_size=1024M  
binlog_format=MIXED  
expire_logs_days=7  
   
###***relay-logparameters  
#relay-log=/data/3307/relay-bin  
#relay-log-info-file=/data/3307/relay-log.info  
#master-info-repository=table  
#relay-log-info-repository=table  
#relay-log-recovery=1  
   
#***MyISAMparameters  
key_buffer_size=16M  
read_buffer_size=1M  
read_rnd_buffer_size=16M  
bulk_insert_buffer_size=1M  
   
#skip-name-resolve  
   
###***master-slavereplicationparameters  
server-id=$SERVERID  
#slave-skip-errors=all  
   
#***Innodbstorageengineparameters  
innodb_buffer_pool_size=512M  
innodb_data_file_path=ibdata1:10M:autoextend  
#innodb_file_io_threads=8  
innodb_thread_concurrency=16  
innodb_flush_log_at_trx_commit=1  
innodb_log_buffer_size=16M  
innodb_log_file_size=512M  
innodb_log_files_in_group=2  
innodb_max_dirty_pages_pct=75  
innodb_buffer_pool_dump_pct=75  
innodb_lock_wait_timeout=50  
innodb_file_per_table=on  
   
[mysqldump]  
quick  
max_allowed_packet=32M  
   
[myisamchk]  
key_buffer=16M  
sort_buffer_size=16M  
read_buffer=8M  
write_buffer=8M  
   
[mysqld_safe]  
open-files-limit=8192  
log-error=/data/mysql/error.log  
pid-file=/data/mysql/mysqld.pid  

更多細節:http://www.th7.cn/db/mysql/201609/205479.shtml

初始化mysql

mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql --console

修改密碼策略:sql

set global validate_password_policy=0;

 

 

報錯:bash

mysqld --skip-grant-tables報錯:Fatal error: Please read 「Security」 section of the manual to find out how to run mysqld as root
詳見
http://blog.csdn.net/jubincn/article/details/6725582
解決:
mysqld --skip-grant-tables --user=root
相關文章
相關標籤/搜索