标签:问题 eve tran load pid touch user 移动 str
1.下载安装包
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
2.解压文件
tar -zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz
3.移动压缩包到usr/local目录下,并重命名文件
mv /root/mysql-8.0.11-linux-glibc2.12-x86_64 /usr/local/mysql
4. 在MySQL根目录下新建一个文件夹data,用于存放数据
mkdir /usr/local/mysql/data
5. 创建 mysql 用户组和 mysql 用户
groupadd mysql
useradd -g mysql mysql
6.用户和文件夹授权
chown -R mysql.mysql /usr/local/mysql/
7.初始化数据库
创建mysql_install_db安装文件
cd /usr/local/mysql
mkdir mysql_install_db
chmod 777 ./mysql_install_db
touch mariadb.log
chown mysql:mysql mariadb.log
初始化数据库
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
注意:记住这里的这个密码
8.mysql配置
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
修改my.cnf文件
vim /etc/my.cnf
修改配置文件:
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /usr/local/mysql/mysql.sock
character-set-server=utf8
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[client]
socket = /usr/local/mysql/mysql.sock
default-character-set=utf8
[mysqld_safe]
log-error=/usr/local/mysql/mariadb.log
pid-file=/usr/local/mysql/mariadb.pid
9.建立mysql服务
cp -a ./support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
添加到系统服务
chkconfig --add mysqld
10. 配置全局环境变量
vim /etc/profile
在 profile 文件底部添加如下两行配置,保存后退出
export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
export PATH
设置环境变量立即生效
source /etc/profile
11. 启动MySQL服务
service mysql start
12.登录MySQL
mysql -uroot -p密码
这里的密码是第7步数据库初始化完成后的密码
修改密码:
alter user ‘root‘@‘localhost‘ identified by ‘123456‘;
创建用户:
create user ‘ixms‘@‘%‘ identified by ‘genergy@123‘;
授权:
grant all privileges on *.* to ‘ixms‘@‘%‘ with grant option;
刷新权限:
flush privileges;
开放端口:
firewall-cmd --add-port=3306/tcp –permanent
重新加载防火墙:
systemctl reload firewalld
远程连接时会提示:caching-sha2-password 这个问题
进入数据库
mysql -uroot –p123456
修改加密规则
ALTER USER ‘ixms‘@‘%‘ IDENTIFIED BY ‘genergy@123‘ PASSWORD EXPIRE NEVER;
更新一下用户的密码
ALTER USER ‘ixms‘@‘%‘ IDENTIFIED WITH mysql_native_password BY ‘genergy@123‘;
刷新权限
FLUSH PRIVILEGES;
标签:问题 eve tran load pid touch user 移动 str
原文地址:https://www.cnblogs.com/w-ting/p/14607534.html