欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

mysql安装简易版

程序员文章站 2022-07-09 19:23:08
1.安装mysql软件tar -xvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz -C /usr/local/cd /usr/localmvmysql-5.7.20-linux-glibc2.12-x86_64mysqlmkdir -p /data/mysqlgroupadd mysqluseradd -g mysql mysqlchown -R mysql.mysql /usr/local/mysqlchown -R mysql....

1.安装mysql软件

mysql软件下载:https://dev.mysql.com/downloads/mysql/

 

tar -xvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

cd /usr/local

mv mysql-5.7.20-linux-glibc2.12-x86_64 mysql

mkdir -p /data/mysql

groupadd mysql

useradd -g mysql mysql

chown -R mysql.mysql /usr/local/mysql

chown -R mysql.mysql /data/mysql

 

2.修改配置文件

mv /etc/my.cnf /etc/my.cnf.bak

vi /etc/my.cnf

 

[mysqld]

datadir = /data/mysql

socket = /tmp/mysql.sock

character_set_server = utf8

default-time-zone = '+08:00'

port = 3306

[mysqld_safe]

log-error=/data/mysql/mysql.log

pid-file=/data/mysql/mysqld.pid

 

3.安装mysql数据库

/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

 

 

4.配置启动文件到开机初始化目录

cp -r /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

vi /etc/init.d/mysqld

basedir=/usr/local/mysql

datadir=/data/mysql

 

chkconfig mysqld on

#注意保持密码si7FfjGg6f_J

5.启动mysql

/etc/init.d/mysqld start

 

 

6.登陆mysql

#env|grep path查看环境变量,直接增加/usr/local/mysql/bin/mysql也可以

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

#注意password的特殊字符,最好加上'   '号

mysql -u root -p’<password>’

设置密码和远程登录

set password = 'oracle';

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'oracle' WITH GRANT OPTION;

flush privileges;

 

本文地址:https://blog.csdn.net/qq_40687433/article/details/107339379