码迷,mamicode.com
首页 > 数据库 > 详细

Linux下MySQL数据库的安装

时间:2019-02-13 17:00:12      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:val   lte   ODB   note   start   new   群组   更改   ase   

记录详细过程以备使用

1、创建群组及用户

obd:~ # groupadd mysql

obd:~ # useradd -g mysql mysql

2、创建相关目录

obd:~ # mkdir -p /opt/mysql/data

obd:~ # mkdir -p /opt/mysql/tmp

3、解压文件,并修改解压后的文件夹的名称

tar -zxvf mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz

mv mysql-5.7.11-Linux-glibc2.5-x86_64 mysql

mv mysql /opt/

4、初始化数据库

bin/mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data       ---注意记下初始密码

 

obd:/opt/mysql # bin/mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data

 

2018-11-15T10:17:50.782341Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2018-11-15T10:17:51.195532Z 0 [Warning] InnoDB: New log files created, LSN=45790

2018-11-15T10:17:51.266087Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2018-11-15T10:17:51.336775Z 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: b553d43d-e8bf-11e8-84c5-000c296c182a.

2018-11-15T10:17:51.341835Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.

2018-11-15T10:17:51.344683Z 1 [Note] A temporary password is generated for root@localhost: !kt6ul-e&u3J

 

复制配置文件/etc/my.cnf

cp support-files/my-default.cnf /etc/my.cnf

 

vim /etc/my.cnf

 

[client]

socket = /opt/mysql/tmp/mysql.sock

[mysqld]

basedir = /opt/mysql

datadir = /opt/mysql/data

port = 3306

socket = /opt/mysql/tmp/mysql.sock

 

权限修改

chgrp -R mysql .

chown -R root .

chown -R mysql data

chown -R mysql.mysql ../mysql

开机启动

cp support-files/mysql.server /etc/init.d/mysql

chmod +x /etc/init.d/mysql

 

chkconfig --add mysql

 

/opt/mysql/bin

软连接

ln -s /opt/mysql/bin/mysql  /usr/local/bin

ln -s /opt/mysql/bin/mysqladmin  /usr/local/bin

ln -s /opt/mysql/bin/mysqld_safe  /usr/local/bin

 

 

开启MySQL

service mysql start

mysql -u root -p     ---初始密码

 

更改密码

alter user root@localhost identified by ‘123456‘;

 

 

更改IP登录权限

use mysql;

grant all privileges  on *.* to root@‘%‘ identified by "123456";

flush privileges;     ---立即生效

 

select host, user from user;

Linux下MySQL数据库的安装

标签:val   lte   ODB   note   start   new   群组   更改   ase   

原文地址:https://www.cnblogs.com/csyd/p/10370616.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!