分类:工具的日常安装及卸载
作者:屈三岁
1.获取MySql
https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.18-el7-x86_64.tar.gz
2.解决依赖工具
yum -y install wget cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel
3.创建目录和用户
mkdir /usr/local/mysql
mkdir /usr/local/mysql/data
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
cd /usr/local/mysql
chown-R mysql:mysql ./ (在/usr/local/mysql)
4. 创建mysql安装初始化配置文件my.cnf
vi /etc/my.cnf
[mysqld]
# 设置3306端口
port=3306
# 设置mysql的安装目录
basedir=/usr/local/mysql
# 设置mysql数据库的数据的存放目录
datadir=/usr/local/mysql/data
# 允许最大连接数
max_connections=500
# 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统
max_connect_errors=10
# 服务端使用的字符集默认为utf8mb4
character-set-server= utf8mb4
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 默认使用“mysql_native_password”插件认证
default_authentication_plugin=mysql_native_password
[mysql]
# 设置mysql客户端默认字符集
default-character-set= utf8mb4
[client]
# 设置mysql客户端连接服务端时默认使用的端口
port=3306
default-character-set= utf8mb4
5.解压安装包
tar -zvxf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz -C /usr/local/mysql
6. 初始化
cd /usr/local/mysql/mysql8xxxx/bin
bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data/
7.启动mysql
bin/mysqld_safe --user=mysql &
8.修改账号密码
bin/mysql -uroot -p(输入在初始成功后显示的密码)
mysql>alter user 'root'@'localhost' identified by "123456";
mysql> create user root@'%' identified by '123456';
mysql>grant all privileges on *.* to root@'%';
mysql>flush privileges;