安装
1、解压
tar –zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
创建mysql用户
/home/mysql下
mkdir data
chown -R mysql:mysql /home/mysql
2、/home/mysql/bin
./mysqld --initialize --user=mysql --basedir=/home/mysql --datadir= home/mysql /data
2017-10-11T02:10:36.844065Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-10-11T02:10:37.220327Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-10-11T02:10:37.288420Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-10-11T02:10:37.354937Z 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: 5f48343d-ae29-11e7-89e2-0050568f1505.
2017-10-11T02:10:37.356848Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-10-11T02:10:37.359582Z 1 [Note] A temporary password is generated for root@localhost: )_8JUWv1DfPm
./mysql_ssl_rsa_setup --datadir=/home/mysql/data
修改配置文件:
cp /home/mysql/support-files/my-defaut.cnf /etc/my.cnf
cp /home/mysql/support-files/mysql.server /etc/init.d/mysqld
修改my.cnf
在mysqld中添加basedir 和datadir
——————————————————————————————————————————————————————————————————————————————
Mysql_safe –user=mysql
查看日志报错:var/log/mysqld.log
执行:
./mysqld --defaults-file=/etc/my.cnf --user=mysql
修改server-key.pem权限为777,执行不报错
Kill 进程后通过mysqld_safe 启动
./mysqld_safe --user=mysql&
查看进程,已启动
用root登录,输入临时密码
./mysql --user=root –p
[root@SD-YTHLbpmceshiA0110141443 bin]# find / -name 'mysql.sock';
/var/lib/mysql/mysql.sock
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
再次登录:
./mysql --user=root –p
Ok
set password=password('mysql'); -----括号中为新密码
grant all privileges on *.* to root@localhost;
mysql> flush privileges;
mysql> use mysql
mysql> select host,user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
3 rows in set (0.00 sec)
添加系统路径
Vi /etc/profile
添加
export PATH=/home/mysql:$PATH
export PATH=/opt/mysql/bin:$PATH
配置mysql自动启动
Chmod 755 /etc/init.d/mysqld
Chkconfig –add mysqld
Chkconfig –level 345 mysql on
删除开机启动
Chkconfig –del mysqld