wget https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpmrpm -Uvh mysql57-community-release-el6-9.noarch.rpm yum install mysql-community-serverservice mysqld startmysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:grep 'temporary password' /var/log/mysqld.log修改默认密码mysql -uroot -pSET 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.cnf
[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
初始化
mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql --console
修改密码策略:
set global validate_password_policy=0;
报错:
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