1.my.cnf配置文件参数:
vim /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysql]
no-auto-rehash
[mysqld]
user = mysql
port = 3306
socket = /tmp/mysql.sock
basedir = /aliyun/server/mysql-5.7.12/
datadir = /data/mysql/data/
open_files_limit = 1024
back_log = 600
max_connections = 800
max_connect_errors = 3000
table_cache = 614
external-locking = FALSE
max_allowed_packet =8M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 100
thread_concurrency = 2
query_cache_size = 2M
query_cache_limit = 1M
query_cache_min_res_unit = 2k
thread_stack = 192K
tmp_table_size = 2M
max_heap_table_size = 2M
long_query_time = 1
pid-file = /data/mysql/mysql.pid
log-bin = /data/mysql/logs/bin-log/mysql-bin
server_id = 1
relay-log = /data/mysql/logs/relay-log/relay-bin
relay-log-info-file = /data/mysql/relay-log.info
binlog_cache_size = 1M
max_binlog_cache_size = 1M
max_binlog_size = 2M
expire_logs_days = 7
key_buffer_size = 16M
read_buffer_size = 1M
read_rnd_buffer_size = 1M
bulk_insert_buffer_size = 1M
lower_case_table_names = 1
skip-name-resolve
slave-skip-errors = 1032,1062
replicate-ignore-db=mysql
innodb_additional_mem_pool_size = 4M
innodb_buffer_pool_size = 32M
innodb_data_file_path = ibdata1:10M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 4M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0
[mysqldump]
quick
max_allowed_packet = 2M
[mysqld_safe]
log-error=/data/mysql/logs/error.log
pid-file=/data/mysql/mysqld_safe.pid
2.安装过程:
useradd mysql -s /sbin/nologin -M
mkdir /aliyun/server -p
mkdir /data/mysql/{logs,data} -p
mkdir /data/mysql/logs/{relay-log,bin-log} -p
tar xf /aliyun/soft/mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz -C /aliyun/server/
mv /aliyun/server/mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz /aliyun/server/mysql-5.7.12
cd /aliyun/serever
ln -s mysql-5.7.12 mysql
chown -R mysql:mysql /data/mysql
chown -R mysql:mysql /aliyun/server/mysql-5.7.12
cd /aliyun/server/mysql-5.7.12/
./bin/mysqld --initialize --user=mysql --basedir=/aliyun/server/mysql-5.7.12/ --datadir=/data/mysql/data
mysql5.7在初始化时,会默认生产一串随机的密码
VeU3gVM85K*p 初始化生成的密码
cp /aliyun/server/mysql/support-files/my-default.cnf /etc/my.cnf
cp /aliyun/server/mysql-5.7.12/support-files/mysql.server /etc/init.d/mysql
chkconfig --add mysql
chkconfig mysql on
cp /aliyun/server/mysql/bin/* /usr/local/sbin/
或者是ln -s /aliyun/server/mysql/bin/* /usr/local/sbin/ 做软连接代替cp复制
重启mysql:
/etc/init.d/mysqld start
/etc/init.d/mysqld stop
3.修改初始化密码:
mysql -uroot -p"VeU3gVM85K*p"
修改初始化密码
mysql> alter user user() identified by ‘123456‘;
到此处二进制安装完毕
4.mysql 5.7.12安装完后登陆报错提示密码过期:
mysql 5.7.12安装完后登陆报错,意思是密码过期
[[email protected] mysql]# mysql -uroot -p‘qajHy,Gwa7jr‘
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
mysqld_safe --user=mysql--datadir=/data/mysql/data --skip-grant-tables --skip-networking &
这样就可以免密码登录了。
然后修改该用户密码过期策略为N:
update mysql.user set password_expired="N" where user="root";
flush privileges;
mysql> \q
service mysql restart
重启mysql,用过期的密码就可以登陆了,登陆之后可以用下面的命令修改密码
>alter user user() identified by ‘123456‘;
Query OK, 0 rows affected (0.03 sec)
>flush privileges;
Query OK, 0 rows affected (0.03 sec)
原文地址:http://blog.51cto.com/wujianwei/2066128
时间: 2024-10-11 20:59:43