
[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
sudo yum install -y mysql-community-server
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
主要修改datadir、socket的路径
service mysqld restart
mysql能够正常启动后,先修改/etc/my.cnf,在[mysqld]下添加skip-grant-tables,意思是数据库启动的时候 跳跃权限表的限制,不用验证密码,直接登录
[myslqd]...skip-grant-tables...
保存后重启服务
service mysqld restart
mysql -uroot -p
直接回车就可以登录进去
登录后,执行
update mysql.user set authentication_string=password('123456') where user= 'root';FLUSH PRIVILEGES;
即:设置root用户的密码是123456。下次登录就可以使用密码登录。注意要将/etc/my.cnf中skip-grant-tables去掉,并重启mysqld服务
通过密码登录后,可能会提示要reset用户的密码,需要执行下面重置密码的命令:
alter user 'root'@'localhost' identified by '123456';
如果执行失败,提示密码策略错误,说明当前的密码不满足默认的策略,要么修改的密码包含字母、数字、特殊字符。要么修改默认的密码策略:
set global validate_password.policy=0; #设置为弱口令
/
关
注
我
们
/

/ 微信号 / 程序老哥/
文章转载自程序老哥,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




