目录
一.初始化环境并解压
二.创建程序用户管理
三.修改mysql目录和配置文件的权限
四.修改配置文件
五.设置环境变量,申明/宣告mysql命令便于系统识别
六.初始化数据库
七.设置系统识别,进行操作
八.初始化数据库密码
九.用户并设置密码
十.赋予远程连接的权限
一.初始化环境并解压
tar -xf mysql-8.0.30-el7-x86_64.tar.gz
mv mysql-8.0.30-el7-x86_64 mysqlmv mysql /usr/local/
二.创建程序用户管理
useradd -s /sbin/nologin mysql
三.修改mysql目录和配置文件的权限
chown -R mysql:mysql /usr/local/mysql/chown mysql:mysql /etc/my.cnf
四.修改配置文件
[client]
port = 3306
socket=/usr/local/mysql/mysql.sock[mysqld]
user = mysql
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
port = 3306
character-set-server=utf8
pid-file = /usr/local/mysql/mysqld.pid
socket=/usr/local/mysql/mysql.sock
bind-address = 0.0.0.0
skip-name-resolve
max_connections=2048
default-storage-engine=INNODB
max_allowed_packet=16M
server-id = 1
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
五.设置环境变量,申明/宣告mysql命令便于系统识别
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profilesource /etc/profile
六.初始化数据库
./mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
七.设置系统识别,进行操作
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqldchmod +x /etc/init.d/mysqldsystemctl daemon-reloadsystemctl restart mysqld
八.初始化数据库密码
mysqladmin -u root -p password "123456"
九.用户并设置密码
mysql -u root -p123456CREATE USER 'root'@'%' IDENTIFIED BY '123456';
十.赋予远程连接的权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';flush privileges;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';