版本:
mysql Ver 14.14 Distrib 5.7.19, for linux-glibc2.12 (x86_64) using EditLine wrapper
安装包:
mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
解压:
[root@rhel6 mysql]#tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
文件夹改名(方便):
[root@rhel6 mysql]#mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql
再新建mysql的用户和用户组:
[root@rhel6 mysql]# groupadd mysql
[root@rhel6 mysql]# useradd -r -g mysql mysql
创建配置文件:
vim /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
basedir=/u01/mysql
datadir=/u01/mysql/data
socket=/tmp/mysql.sock
log-error=/u01/mysql/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
lower_case_table_names = 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
max_connections=5000
default-time_zone = '+8:00'
log-bin=/u01/mysql/log/mysql-bin
server-id=10241
修改权限:
[root@rhel6 u01]# chown -R mysql:mysql mysql
初始化:
[root@rhel6 u01]# mysqld --initialize --user=mysql --basedir=/u01/mysql --datadir=/u01/mysql/data --lc_messages_dir=/u01/mysql/share --lc_messages=en_US
2018-12-26T21:51:58.320354Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-12-26T21:51:58.914975Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-12-26T21:51:59.004806Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-12-26T21:51:59.092588Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7842c967-0958-11e9-9f6c-000c296ee978.
2018-12-26T21:51:59.095301Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-12-26T21:51:59.096011Z 1 [Note] A temporary password is generated for root@localhost:
创建文件mysqld.pid,mysqld.log:
[root@rhel6 mysqld]# vim mysqld.pid
[root@rhel6 mysqld]#chmod 777 mysqld.pid
[root@rhel6 mysqld]#chown mysql:mysql mysqld.pid
启动服务并登陆:
/usr/local/mysql/support-files/mysql.server start
/usr/local/mysql/bin/mysql -uroot -p你在上面看到的初始密码
加入到系统服务中:
[root@rhel6 support-files]#cp mysql.server /etc/init.d/mysqld
[root@rhel6 support-files]#chkconfig --add mysqld
[root@rhel6 support-files]#chkconfig mysqld on
[root@rhel6 support-files]#service mysqld restart
重置密码:
[root@rhel6 support-files]# mysql -uroot -p
mysql> set password=password('Cqmyg14dss');
mysql> flush privileges;
开启binlog:
my.cnf中添加配置
log-bin=/u01/mysql/log/mysql-bin
server-id=10241
Mysql学习总结之安装配置
最新推荐文章于 2023-10-10 20:32:56 发布