yum install epel-release -y yum install gcc -y yum install libgcc gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers glibc-util glibc-static libcurl libcurl-devel libconfig libconfig-devel -y yum install ncurses-devel ncurses -y yum install zip unzip -y yum install lrzsz -y yum install pcre pcre-devel pcre-static zlib zlib-devel zlib-static openssl openssl-devel openssl-static -y yum install libaio libaio-devel libgcc libgcc-devel libstdc++ libstdc++-devel -y yum install curl wget iputils nmap-ncat bind-utils openssh-clients lftp -y yum install libffi-devel -y yum install tcl tclx tcl-devel -y yum install expect -y wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.22-linux-glibc2.12-x86_64.tar.xz xz -d mysql-8.0.22-linux-glibc2.12-x86_64.tar.xz tar -xvf mysql-8.0.22-linux-glibc2.12-x86_64.tar groupadd mysql useradd -g mysql mysql passwd mysql cp -a mysql-8.0.22-linux-glibc2.12-x86_64 /home/mysql/mysql8.0.22 cd /home/mysql/ ln -s mysql8.0.22 mysql8 cd mysql-8.0.22-linux-glibc2.12-x86_64 mkdir data chown -R mysql:mysql mysql8 chown -R mysql:mysql mysql8.0.22 #./mysqld --user=mysql --basedir=/home/mysql/mysql8 --datadir=/home/mysql/mysql8/data/ --initialize --console ./mysqld --user=mysql --basedir=/home/mysql/mysql8 --datadir=/home/mysql/mysql8/data/ --initialize vim /etc/my.cnf 添加修改 [mysqld] basedir=/home/mysql/mysql8/ datadir=/home/mysql/mysql8/data/ socket=/tmp/mysql.sock #socket=/var/lib/mysql/mysql.sock character-set-server=utf8mb4 注释 [mysqld_safe] #log-error=/var/log/mariadb/mariadb.log #pid-file=/var/run/mariadb/mariadb.pid 有这个,请知晓,什么都不改 vim /etc/my.cnf.d/mysql-clients.cnf mkdir /var/lib/mysql chown -R mysql:mysql /var/lib/mysql/ cp -a ./support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld chkconfig --add mysqld chkconfig --list mysqld service mysqld status service mysqld start ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; flush privileges; 查看编码 show variables like '%char%'; 后记: 设置允许远程登录 use mysql; update user set host='%' where user='root'; #update user set user.Host='%' where user.User='root'; flush privileges; #./mysqld --user=mysql --basedir=/home/mysql/mysql8 --datadir=/home/mysql/mysql8/data/ --initialize --console ./mysqld --user=mysql --basedir=/home/mysql/mysql8 --datadir=/home/mysql/mysql8/data/ --initialize 2021-02-03T09:20:20.739066Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release. 2021-02-03T09:20:20.739171Z 0 [System] [MY-013169] [Server] /home/mysql/mysql8.0.22/bin/mysqld (mysqld 8.0.22) initializing of server in progress as process 28278 2021-02-03T09:20:20.749609Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2021-02-03T09:20:21.221188Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2021-02-03T09:20:22.307392Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Psdfegsdf8di ./mysqld --user=mysql --basedir=/home/mysql/mysql8 --datadir=/home/mysql/mysql8/data/ --initialize 2021-02-08T01:45:31.812545Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release. 2021-02-08T01:45:31.812644Z 0 [System] [MY-013169] [Server] /home/mysql/mysql8.0.22/bin/mysqld (mysqld 8.0.22) initializing of server in progress as process 27000 2021-02-08T01:45:31.819333Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2021-02-08T01:45:32.260915Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2021-02-08T01:45:33.259762Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Psfdssasfe5gI 其它配置文件/etc/my.cnf [mysqld] # 设置3306端口 port=3306 # 设置mysql的安装目录 basedir=/usr/local/mysql # 设置mysql数据库的数据的存放目录 datadir=/usr/local/mysql/mysqldb # 允许最大连接数 max_connections=10000 # 允许连接失败的次数。这是为了防止有人从该主机试图攻击数据库系统 max_connect_errors=10 # 服务端使用的字符集默认为UTF8 character-set-server=utf8 # 创建新表时将使用的默认存储引擎 default-storage-engine=INNODB # 默认使用“mysql_native_password”插件认证 default_authentication_plugin=mysql_native_password [mysql] # 设置mysql客户端默认字符集 default-character-set=utf8 [client] # 设置mysql客户端连接服务端时默认使用的端口 port=3306 default-character-set=utf8