Linux mysql安装笔记

参考:
mysql在linux下的安装
linux下安装mysql

下面是自己安装的时候一些总结,仅供参考

1 下载
下载地址:MySql下载地址

//安装包:mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

2 解压

//解压
tar -zxvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz
//复制解压后的mysql目录
cp -r mysql-5.7.21-linux-glibc2.12-x86_64 /usr/local/mysql

3 添加用户组合和用户

//添加用户组
groupadd mysql
//添加用户mysql 到用户组mysql
useradd -g mysql mysql

4 安装

//进去mysql目录
cd /usr/local/mysql/
//加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了
export MYSQL=/usr/local/mysql
export PATH=$PATH:$MYSQL/bin
//创建data/mysql目录
mkdir -p /data/mysql
//修改权限
chown -R mysql:mysql ./
//初始化mysql数据库
./bin/mysqld  --initialize  --user=mysql --datadir=/usr/local/mysql/data/mysql
//输出如下:JpUgf=qp1tlk 为初始化密码
//*************************************************
2018-06-21T09:50:54.854264Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-06-21T09:50:55.542378Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-06-21T09:50:55.613562Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-06-21T09:50:55.692791Z 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: 979adf56-7538-11e8-b92d-fa163e33a982.
2018-06-21T09:50:55.693724Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-06-21T09:50:55.694165Z 1 [Note] A temporary password is generated for root@localhost: JpUgf=qp1tlk
//*************************************************
//复制mysqld
cp support-files/mysql.server /etc/init.d/mysqld
//修改权限
chmod 755 /etc/init.d/mysqld

//修改启动脚本
vi /etc/init.d/mysqld

//修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql

//启动服务
service mysqld start

//登录mysql
./mysql/bin/mysql -uroot -pJpUgf=qp1tlk

//操作数据mysql,需要重新修改密码
set password for root@localhost = password('password');

5 mysql启停命令:

//启动mysql
service mysqld start
//关闭mysql
service mysqld stop
//查看运行状态
service mysqld status

6 授权:

//授权后方便使用可视化工具登录和其他机器登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '973hao130' WITH GRANT OPTION;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值